r/DatabaseHelp • • 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!

1 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/Is_At_Work Oct 02 '16

Also some thoughts on what you've provided:

  • Is CompanyName intentionally nullable or is that a typo?
  • Should your name fields, Address, and City really be CHAR?
  • I know this is homework, but as a thought experiment (and to help you in your career if you work on databases in the future) consider the following:
  • What about people with more names than first and last?
  • Are your name and address field lengths enough?
  • Since you have City, State, and ZIP I assume you are designing for US only, but consider that other countries may have Province or nothing in place of State, and ZIP (Postal Code) is longer in other countries. Also, you used CHAR for ZIP, had you used a number you would not be able to handle many other countries.
  • Why are Phone and Fax 12 characters? Are you planning on storing formatted data (e.g. 123-123-1234)? This is typically not a good practice, store it raw and format it later.