Results 1 to 6 of 6
Aug 18, 2012, 08:55 #1
MySQL check if value exists in another table
I have three tables, one table, vendors, holds a vendor name and an id, the second table, vendorlinks, has two columns vendorID and pageID, the id in vendors has the same value as vendorID in vendorLinks, and the third table page has the column page id which matches up to pageID in vendorlinks.
So basically I have a type of multiple pages correspond to multiple vendors system, and I need to display a page that contains all the pages that correspond to the vendor but also have pageIDs that correspond to the pages table pageId column, as not all entries in vendorlink correspond to a particular page entry.
What I need is a sql statement that will probably look something like this
'SELECT * FROM VendorLink Where vendorID = :venId And' pageId matches with ID IN pages table
That last part is what I don't know how to do. Any help is alwaya aprreciated.
Maxdream01PHP is FUN
Aug 18, 2012, 09:21 #2
Nevermind everyone i solved it here's my solution i fanyone is interested:
'SELECT * FROM VendorLink Where vendorID = :venId AND pageID IN (SELECT id FROM Pages)''PHP is FUN
Aug 18, 2012, 11:42 #3
- Join Date
- Jul 2002
- Toronto, Canada
- 49 Post(s)
- 1 Thread(s)
Aug 18, 2012, 12:30 #4
Oh no, im calculating the vendor id with another statement, since there is also other information I need to get from that table.PHP is FUN
Aug 18, 2012, 12:32 #5"Folks who know what they're doing make complexity seem simple."
Aug 18, 2012, 12:50 #6