S
Steve
If that's even the best way, I don't know.
Here are the basic tables I have:
Tbl_Products
[ProdId (pk)] [Name]
Tbl_Prod_Faqs
[ProdId(fk)] [FaqId(fk)]
Tbl_Prod_Images
[ProdId(fk)] [ImgId(fk)]
OK, I would like to execute a query that will return all the Products from
Tbl_Products that have entries in Tbl_Prod_Faqs, Tbl_Prod_Images and any
other many-to-many tables that have a ProdId (fk)
I can think of very clunky, ugly ways to do this, but I am looking for the
correct way to ask "Gimme all the records that have Faq data, Images, Etc"
This is what I came up with at first
SELECT DISTINCT PF.ProdId FROM Tbl_Prod_Faqs AS PF
LEFT JOIN Tbl_Products AS P ON PF.ProdId = P.ProdId
So this will get me the Product data for anything listed in the
Tbl_Prod_faqs, but what about Tbl_Prod_Images? How can I do that one
without having a second SELECT statement? Then, if I did have 2 select
statements, how can I merge them using my Stored Procedure into 1 table or
result? I don't even know where to start.
Despite my basic ".....heeeeelp me" approach to this, if someone could
simply send me in the right direction, I can figure it out.. currently I
just can't see the whole picture or a good starting point.
Any help appreciated.
Thanks,
Steve
Here are the basic tables I have:
Tbl_Products
[ProdId (pk)] [Name]
Tbl_Prod_Faqs
[ProdId(fk)] [FaqId(fk)]
Tbl_Prod_Images
[ProdId(fk)] [ImgId(fk)]
OK, I would like to execute a query that will return all the Products from
Tbl_Products that have entries in Tbl_Prod_Faqs, Tbl_Prod_Images and any
other many-to-many tables that have a ProdId (fk)
I can think of very clunky, ugly ways to do this, but I am looking for the
correct way to ask "Gimme all the records that have Faq data, Images, Etc"
This is what I came up with at first
SELECT DISTINCT PF.ProdId FROM Tbl_Prod_Faqs AS PF
LEFT JOIN Tbl_Products AS P ON PF.ProdId = P.ProdId
So this will get me the Product data for anything listed in the
Tbl_Prod_faqs, but what about Tbl_Prod_Images? How can I do that one
without having a second SELECT statement? Then, if I did have 2 select
statements, how can I merge them using my Stored Procedure into 1 table or
result? I don't even know where to start.
Despite my basic ".....heeeeelp me" approach to this, if someone could
simply send me in the right direction, I can figure it out.. currently I
just can't see the whole picture or a good starting point.
Any help appreciated.
Thanks,
Steve