sql="SELECT Products.ProductID, Products.SubCategoryID FROM Products"
any help would be appreciated.I've come up with the following, i'm not sure if this is the correct way to do it, but it seems to work. I ran it through SQL Query Analyzer and it appears to give the results that i was expecting.
sql="SELECT Products.ProductID, Products.SubCategoryID, (SELECT CategoryID FROM SubCategories WHERE SubCategoryID = Products.SubCategoryID) as CategoryID
FROM Products";
If there is another/better/correct way to do this please let me know. Thanks.|||Another way to do it, which might be more efficient, is:
sql="SELECT Products.ProductID, Products.SubCategoryID, SubCategories.CategoryID FROM Products LEFT OUTER JOIN SubCategories ON Products.SubCategoryID = SubCategories.SubCategoryID";
Terri|||Very good, thanks. That is exactly what I was looking for.
No comments:
Post a Comment