Hi all, I'm a n00b here and I'm loving it!
This is my first post so I appologize for any and all errors I make.
I'd like to ask a question about a sql query,
I have no idea how to join tables, so a little
help would come very handy!
Here are three queries that will get me what I need,
but I want to turn them into only one query if possible.
I start out by knowing the trade_id, which is '1':
SELECT seller_id FROM relations WHERE trade_id = '1';
--- result -------------------
seller_id: '2'
Then, I need to get the location_id from the sellers table using the seller_id:
SELECT location_id FROM sellers WHERE seller_id = '2';
--- result -------------------
location_id: '338'
And finally, I need to get the location title from locations table using the location_id:
SELECT location_title FROM locations WHERE location_id = '338'
--- result -------------------
location_title: Stockholm
I've read most any tutorial I can find on the subject
but I cant seem to understand what's going on in them..
I've tried this with no luck:
SELECT location_title
FROM locations
INNER JOIN relations ON trade_id = '1'
INNER JOIN sellers ON sellers.seller_id = relations.seller_id
Anyone have any suggestions or pointers?
Many thanks for reading!