條件:數(shù)字
select * from table where col = 1;
條件:文本
select * from table where col like '%jin';
排序(rows)
需要對(duì)結(jié)果rows排序和篩選部分rows
select * from table
where col > 1 order by col asc limit 2 offset 2
join:連表(table)
當(dāng)查找的數(shù)據(jù)在多張關(guān)聯(lián)table里
select * from table1 left join table2
on table1.id = table2.id where col > 1
算式(select / where)
當(dāng)需要對(duì)select的col 或 where條件的col 經(jīng)過一定計(jì)算后才能使用
select *,col*2 from table where col/2 > 1
統(tǒng)計(jì)(select)
對(duì)查找的rows需要按col分組統(tǒng)計(jì)的情況
select count(*),avg(col),col
from table
where col > 1 group by col
子表 (table)
一次select的結(jié)果rows作為下一次select的臨時(shí)table才能得到最終結(jié)果
select * from
(select * from table where col > 1)
as tmp where col < 1