Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A student wants the name and the price of every product in a shop table called Products. He writes:
SELECT Name Price,
FROM Product;Find every error in the script and write it correctly. How many errors are there?
A query starts SELECT (the fields to output, with commas between them, in the order you want) and FROM (the table). A semicolon ends it. With no condition, every record is output, in the order of the table.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Step 1. Between the fields. Name Price has no comma. It must be Name, Price.
Step 2. After the last field. There is a comma before FROM. It must go.
Step 3. The table name. The table is Products, not Product.
Answer: errors. The correct script is SELECT Name, Price FROM Products;.
Log in to join the discussion.
Loading…