Difference between revisions of "Select Queries"
(→Basic Example) |
|||
Line 19: | Line 19: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | Remember the | + | Remember the ''select'' can have * to select all fields, however questions will normally specify what fields to select. The '''from''' section should identify which table(s) to select the data from. The '''where''' section should include the criteria used to select the data, this could be a simple statement as above but remember you can also include other operators such as '''and'' '''or''' '''not''' '''like''' and so on. |
Revision as of 12:50, 17 December 2016
- Used for fetching information from an SQL database.
- 'Outputs' the data once successfully selected
- Allows selection from multiple tables but not multiple databases.
The Basic Construct
SELECT `data` FROM `TABLE`
WHERE `Condtion`
ORDER BY `TABLE` ASC / DESC ;
Basic Example
SELECT *
FROM Book
WHERE price > 100.00
ORDER BY title;
Remember the select can have * to select all fields, however questions will normally specify what fields to select. The from' section should identify which table(s) to select the data from. The where section should include the criteria used to select the data, this could be a simple statement as above but remember you can also include other operators such as and or not like and so on.