| Welcome to WebmasterWorld Guest from 18.104.22.168 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|JOIN does not outputs data from only one table|
I'm trying to pull data from two tables, Details and Variables. The SQL query below gives me data from Details, but nothing from Variables when I loop throught the results array.
$query = "SELECT Details.Description, Details.DetailValue, Variables.VariableName, Variables.Value
INNER JOIN SavedConfigurations
INNER JOIN Variables
ON Variables.OrderID = SavedConfigurations.OrderID
WHERE Variables.VariableName = 'URL1'
Can anyone please offer suggestions?
Just a note: you are connected to 3 tables
Have you try LEFT or RIGHT OUTTER JOIN? If I remember correctly the inner join will fail if any of the table don't have a value for the joining key.
It means there are no columns that match the criteria . . . when fuzzled with joins, break down the statements. Output the joining column and do a straight select . . .
SELECT Details.OrderID, Details.Description, Details.DetailValue Details
Now pick one of the order ID's and compare it with straight selects on the other two tables.
SELECT SavedConfigurations.OrderID from SavedConfigurations where SavedConfigurations.OrderID = 'one-of-the-order-ids' AND SavedConfigurations.Name='TEST123'
"SELECT Variables.VariableName, Variables.Value
FROM Variables where Variables.OrderID = 'one-of-the-order-ids' and Variables.VariableName = 'URL1'
You'll probably find an empty set for at least one of the two joins.
Thanks for the help, I will try your suggestions!
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved