maxdream01 — 2012-08-18T12:55:33-04:00 — #1
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.
maxdream01 — 2012-08-18T13:21:00-04:00 — #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)''
r937 — 2012-08-18T15:42:13-04:00 — #3
you be missing a table in there
maxdream01 — 2012-08-18T16:30:24-04:00 — #4
Oh no, im calculating the vendor id with another statement, since there is also other information I need to get from that table.
jeff_mott — 2012-08-18T16:32:18-04:00 — #5
It's great that you solved your own problem, but I have to admit, this requirement baffles me a bit. How could you have a vendorLink pageID that doesn't correspond to a page entry? Where did the value of the pageID even come from if there's no corresponding page?
maxdream01 — 2012-08-18T16:50:08-04:00 — #6
Users are allowed submit pages which we keep in a seperate tablebefore confirmation, so when we display pages that pertain to a certain vendor we want to make sure there is no evidence of another page linking to that vendor, that we don't show.
mittineague — 2014-09-18T23:33:26-04:00 — #7
This topic is now archived. It is frozen and cannot be changed in any way.