Jump to content

[SOLVED] MySQL Join Query


Omzy

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/180413-solved-mysql-join-query/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.