Jump to content

[SOLVED] getting all values from three different tables .. JOIN problem?


krio

Recommended Posts

I'm learning mysql and have been trying to get this working, but an error always comes up no matter how I try it - or it just doesn't show anything from the table.

 

I have 3 tables, all with the same amount of columns and name of columns

 

I want to list all the values in alphabetical order by title

 

Tables: General - Temp - Location

 

Columns:  id - url - title - description

 

How would you  write the select statement?

 

I have tried numerous ways and can't figure it out... I'm guessing it would look something like

 

SELECT * FROM General JOIN Temp ON General.title = Temp.title JOIN Location ON Temp.title = General.title

 

I have played around extensively with changing the values like Temp.title = General.title and that doesnt seem to help

 

Any ideas?

 

Thanks!

 

Link to comment
Share on other sites

SELECT 
General.id,
General.url,
General.title,
General.description,
Temp.id,
Temp.url,
Temp.title,
Temp.description,
Location.id,
Location.url,
Location.title,
Location.description
FROM 
General INNER JOIN Temp
ON General.id = Temp.id
INNER JOIN Location
ON Temp.id = Location.id
ORDER BY
General.title

 

Will this work?

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.