select "column1"[,"column2",etc] from "tablename" [where "condition"]; [] = optional
select first, last, city from empinfo where first LIKE 'Er%';
select first, last from empinfo where last LIKE '%s';
select * from empinfo where first = 'Eric';
这里有一个名为"empinfo"的表:
first |
last |
id |
age |
city |
province |
Zhang |
Jiangsheng |
95123043 |
23 |
汕头 |
广东 |
Huang |
Weidong |
98122001 |
23 |
深圳 |
广东 |
Li |
Simin |
98111234 |
34 |
珠海 |
广东 |
Zhang |
Sanmei |
99232211 |
26 |
厦门 |
福建 |
Jiang |
Dongsheng |
98000190 |
28 |
重庆 |
四川 |
Liu |
Tongxin |
97231231 |
31 |
海南 |
海南 |
select first, last, city from empinfo;
first |
last |
id |
Zhang |
Jiangsheng |
95123043 |
Huang |
Weidong |
98122001 |
Li |
Simin |
98111234 |
Zhang |
Sanmei |
99232211 |
Jiang |
Dongsheng |
98000190 |
Liu |
Tongxin |
97231231 |
select last, city, age from empinfo where age > 30;
last |
city |
age |
Simin |
汕头 |
34 |
Tongxin |
海南 |
31 |
select first, last, city, province from empinfo where first LIKE 'J%';
first |
last |
city |
Province |
Jiang |
Dongsheng |
重庆 |
四川 |
select * from empinfo;
first |
last |
id |
age |
city |
province |
Zhang |
Jiangsheng |
95123043 |
23 |
汕头 |
广东 |
Huang |
Weidong |
98122001 |
23 |
深圳 |
广东 |
Li |
Simin |
98111234 |
34 |
珠海 |
广东 |
Zhang |
Sanmei |
99232211 |
26 |
厦门 |
福建 |
Jiang |
Dongsheng |
98000190 |
28 |
重庆 |
四川 |
Liu |
Tongxin |
97231231 |
31 |
海南 |
海南 |
select first, last, from empinfo where last LIKE '%g';
first |
last |
Zhang |
Jiangsheng |
Huang |
Weidong |
Jiang |
Dongsheng |
select first, last, age from empinfo where last LIKE '%sh%';
first |
last |
age |
Zhang |
Jiangsheng |
23 |
Jiang |
Dongsheng |
28 |
select * from empinfo where first = 'Jiang';
first |
last |
id |
age |
city |
province |
Jiang |
Dongsheng |
98000190 |
28 |
重庆 |
四川 |