homepage Welcome to WebmasterWorld Guest from 54.167.173.250
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Need help with a JOIN
Joining 3 tables
EvertVd




msg:4391280
 2:17 pm on Nov 26, 2011 (gmt 0)

Maybe a lame excuse but I need help because I have a horrible flu with a headache, watery eyes and a deadline. And JOINs have never been a strong suit of mine so after staring at this problem for 4 hours now I admit I need help.

I have 3 tables:

product
id
name
type
status

categories
id
parent
cat

xref
id
catID
prodID

I need to have a list of all the categories (can be doubles) of all products where status=X and type=Y

What I have sofar is:

SELECT * FROM xref AS x
LEFT JOIN categories AS c ON x.catID = c.id
LEFT JOIN product AS p ON x.prodID = p.id WHERE status = X AND type = Y;


But it does not seem to work as I expect?
Can anyone help me out here please? Thank you.

 

EvertVd




msg:4391425
 9:57 am on Nov 27, 2011 (gmt 0)

Because of a rewrite of another part of my code I now only need a 2-table join.
With the same tables as above I now have:

SELECT x.catID FROM xref AS x
LEFT JOIN product AS p
ON x.prodID = p.id
WHERE a.status = '{$status}' AND a.type = '{$type}' AND x.prodID = '{$productID}'


But I get no results back?
I hate JOINs, lol.

EvertVd




msg:4391431
 10:56 am on Nov 27, 2011 (gmt 0)

Ok, never mind. There was nothing wrong with neither query, it was another stupid (no doubt flu related, yeah right) mistake later on in my code (I expected the result to be available before I executed it, lol).

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved