Spunky Posted February 15, 2010 Share Posted February 15, 2010 Alright Im going to do my best to explain my situation in a simple manner.2 tables. One table is to display content and the second table establishes an image to display depending on the name of the content. So here we havetable1.name, table2.imageTable 1 and table 2 also share a column in common:table1.points, table2.pointsWhat I want to display is table1.name and table2.image when table1.points = table2.points. Like, depending on how many 'points' is shown depends on the image shown. Let me set up something small for visualtable1Name PointsApple 1Banana 2Chestnut 1Donut 2So as you can see the amount of points can duplicate.table2Image Points1Point 12Point 2The points are only in there once, to match with the image.So say I want to display the table like:Apple 1 1PointBanana 2 2PointChestnut 1 1PointDonut 2 2PointSee how depending on how many points the name has, depends on the 'image' that shows up.*Note* No images are used in the database, just a string of text. All fields are varchar or int/tinyint. Just dont want to make things confusing, nothing special.So, whats the best way to do this? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 16, 2010 Share Posted February 16, 2010 You need to use a join. e.g.:SELECT table1.name, table2.image FROM table1 INNER JOIN table2 ON table1.points=table2.points Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.