Jump to content

Simple query in Mysql that i can't seem to get right! Joining tables


c_shelswell

Recommended Posts

Hi i'm sure this has a very simple answer. I'm looking to query mysql joining two tables. basically i have:

Media
media_id - title - picture

and

Purchases
media_id - quantity

all im looking to do is query mysql for the title of the media_id i give to it from the purchases table. I'm getting some results but i provides me with the title as many times as the media_id appears in purchases i only need it once.

Here's my code.
[code]select media.title, media.picture from media left join purchases using (media_id) where purchases.media_id='4';[/code]

i'm pretty new to mysql and this is really just a guess if anyone could help that would be great.

Thanks very much
Ooops managed to get it. I used this.

[code]select distinct media.title, media.picture from media left join purchases on purchases.media_id=media.media_id where purchases.media_id=4;[/code]


perhaps there's a better way?

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.