Omzy Posted November 5, 2009 Share Posted November 5, 2009 Here is my database structure (simplified): TABLE properties id (PK, INT, AUTO INC) prop_vebraid (INT) TABLE images id (PK, INT, AUTO INC) image_url (VARCHAR) prop_vebraid (INT) I am using MySQL database with MyISAM format, which is why I don't have any foreign keys in the database. I want to retrieve images.image_url where images.prop_vebraid = properties.prop_vebraid But I'm having difficulty doing this. I'm not getting the desired results. Does anyone have any idea how I can do this and output the image url on each match? images.prop_vebraid is not unique by the way. I think I need some sort of inner join? Quote Link to comment Share on other sites More sharing options...
Omzy Posted November 5, 2009 Author Share Posted November 5, 2009 So let's say I have the following: TABLE properties id: 001 prop_vebraid: prop001 TABLE images id: 101 image_url: http://i.com/i1.jpg prop_vebraid: prop001 id: 102 image_url: http://i.com/i2.jpg prop_vebraid: prop001 id: 103 image_url: http://i.com/i3.jpg prop_vebraid: prop001 So for properties.prop_vebraid prop001 it needs to retrieve those 3 rows in images Quote Link to comment Share on other sites More sharing options...
kickstart Posted November 5, 2009 Share Posted November 5, 2009 Hi Just something like this SELECT a.id, b.image_url FROM properties a JOIN images b ON a.prop_vebraid = b.prop_vebraid All the best Keith Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.