General Select Format
SELECT commaSeperatedColumnNames FROM tableName
Below, we will go over the basics of selecting from a table in various situations. Below is a standards table with various columns and various rows. This table will be used through the rest of this article.
Table: members
| id | name | age | gender | state |
|---|---|---|---|---|
| 1 | Victor | 18 | M | CA |
| 2 | Bill | 28 | M | NY |
| 3 | Jill | 5 | F | CA |
| 4 | Bob | 14 | M | AL |
Select All
SELECT * FROM members
Select Males
SELECT * FROM members WHERE gender = ‘M’
Select Age Between 10 and 20
SELECT * FROM members WHERE age between ‘10′ AND ‘20′
Select Distinct States
SELECT distinct(state) FROM members
Select All Names, But Rename Column To FirstName
SELECT name as FirstName FROM members
RSS Feed
Posted in
Tags: 
