Writing Your First Query

The following SQL statement will select all columns from the CHECKS table. The asterisk (*) means “all”.

SQL> select * from checks;
						mysql> select * from checks;
					

Note

Whenever you have a SELECT, you must also have a FROM clause.

The output from this SQL statement is the following:

 CHECK# PAYEE AMOUNT REMARKS ------ ----------------- ------- ------------------- 1 Ma Bell 150 Have sons next time 2 Reading R.R. 245.34 Train to Chicago 3 Ma Bell 200.32 Cellular Phone 4 Local Utilities 98 Gas 5 Joes Stale $ Dent 150 Groceries 6 Cash 25 Wild Night Out 7 Joans Gas 25.1 Gas 7 rows selected. mysql> select * from checks; +-------+-------------------+--------+---------------------+ | check | payee | amount | remarks | +-------+-------------------+--------+---------------------+ ...

Get Sams Teach Yourself SQL in 21 Days, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.