|
![]() |
Simple SQL statements
One of the simplest statements in SQL is retrieving all records in a table.
The syntax for this is SELECT * FROM `tablename` . The asterisk
is a wildcard meaning "everything". This statement will return all fields of all rows in the
table. If you only want some of the fields (columns), or you want them in a certain
order, you can specify them in the statement. SELECT `column_one`, `column_two` FROM
`tablename` . If you want the columns in the other order, your statement would
look like this: SELECT `column_two`, `column_one` FROM
`tablename` . You can also limit the query so it will only return a certain number
of rows, using the LIMIT command. The following statement will only return
the first 3 rows found. SELECT `column_two`, `column_one` FROM
`tablename` LIMIT 3
To be continued...
|
|