MySQL簡單的查詢語句
1、查詢特定列:select 列名 from 表名;(必須先進入數據庫)或者 select 列名 from 數據庫.表名;
2、查詢多個列:select 列1,列2,。。。 from 表名;
3、除去重復列查詢:select distinct 列名 from 表名;
4、設定查詢結果返回的行數:select 列名 from 表名 limit n;select 列名 from 表名 limit n,m; *行號是從0開始
5、查詢結果排序:select 列名1,列名2 from 表名 order by 列名1,列名2;
select 列名1,列名2 from 表名 order by 列名1 desc,列名2 desc; 降序(從大到小)
6、多個關鍵字查詢:select 列名1 from 表名 order by 列名 desc limit 1;
7、過濾where字句 :select 列名 from 表名 where 列名=數值;操作符:等于:=,不等于:<>和!=,小于:<,小于等于:<=,大于:>,大于等于:>=,指定兩個值之間:between
8、組合where字句:操作符:and、or、in、not in
9、用通配符過濾:like %、_
浙公網安備 33010602011771號