r/DatabaseHelp • u/Cloud_The_Stampede • Oct 02 '16
Help with SQL server 2014 Select clauses.
I have an assignment that has been driving me crazy, I have been researching online with helpful information but I believe is beyond my comprehension.
I have two tables one has information about items containing the price of the item, the second has information about the vendor with company name information.
The statement I am supposed to write is going to give me results with data that has greater than 1000$ in price and contain the name "new" in the vendor list.
So far I have:
select ItemID, ItemDescription, CompanyName
from ITEM, VENDOR
Where ItemPrice > 1000 Having like 'New';
I kept getting syntax errors and again have tried to research the problem with no luck please help!
View all comments
Show parent comment
1
u/Grundy9999 Oct 05 '16
There are others here far more knowledgeable than me, but those are the issues I spotted. Assuming that there is an implicit relationship with ItemId as the primary and foreign key, my first attempt would probably be:
select ItemID, ItemDescription, CompanyName from ITEM, VENDOR Where Item.ItemPrice > 1000 and Vendor.CompanyName like "New%";
But I may have missed an issue.
And if a relationship needed to be made between the tables, then a join would have to be specified.