2 常用查詢

2022-08-12 05:54:17 字數 690 閱讀 4286

select * from tablename where columnname = condition

%:多個位置字元;

_ : 乙個未知佔位符

between :value1 and value2

in:value in (valuei,value2)

not in : value not in (valuei,value2)

exists:如果存在返回true。

not exists:如果不存在則返回false

全部插入對應列值

insert into ( [列1], [列2], [列3], [列4], ) values( [值1], [值2], [值3], [值4],);

全部插入,省略列明。

insert into values( [值1], [值2], [值3], [值4],);

部分插入列值對應

insert into ( [列1], [列3],) values( [值1], [ [值3],);

update set = where 更新等值條件 

更新多列時中間用都逗號隔開。set 舊值1=新值1,舊值2=新值2,舊值3=新值3,

update set 可以對數值字段配合數字運算子

delete from where //直接填寫表名 將清空表

drap talbe

mysql 查詢 常用 mysql常用查詢

一.group concat函式,以指定的分割符合並列,與group by 一起用 例 selectgroup concat c.columnname separator group by 二.preparedstatement.return generated keys 得到剛剛插入記錄的id p...

mysql常用的查詢 MySQL常用查詢

資料庫 1.查詢所有資料的大小 data length 資料大小 index length 索引大小 select concat round sum data length index length 1024 1024,2 mb as data from information schema.tab...

mysql常用的查詢 MySQL常用查詢

select from unixtime create time,y m as time,sum sales amount sales amount sum from sales group by time 執行結果如下 查詢每年的銷售額 select from unixtime create ti...