Archive:PHP and MySQL Programming/Basic Queries: Difference between revisions
| Line 9: | Line 9: | ||
The SELECT query is the standard means by which to retrieve information from the database. The syntax for the SELECT query is as follows: | The SELECT query is the standard means by which to retrieve information from the database. The syntax for the SELECT query is as follows: | ||
mysql> SELECT | mysql> SELECT field1, field2, ... | ||
FROM | FROM table_name | ||
[WHERE condition1 | [WHERE condition1 | ||
AND condition2 | AND condition2 | ||
... | ... | ||
[ORDER BY | [ORDER BY field1, field2, etc...] | ||
[LIMIT number]]; | [LIMIT number]]; | ||
Example : | Example : | ||
mysql> SELECT * FROM | mysql> SELECT * FROM books`; | ||
mysql> SELECT | mysql> SELECT Title, Author` | ||
FROM | FROM books` | ||
WHERE | WHERE Year > 2001 | ||
AND | AND Year < 2006 | ||
ORDER BY | ORDER BY Author ASC | ||
LIMIT 100; | LIMIT 100; | ||