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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.