1、給數據表添加一組數據: 2、給數據表添加多組數據: 3、對數據進行刪除和修改: 4、用select查詢單個或多個數據信息: 5、去除重覆值: 6、查詢的各種用法: between的用法: 查詢排序: limit的用法: 分組: 查詢總數: 起別名: select *from 表 where id ...
1、給數據表添加一組數據:
2、給數據表添加多組數據:
3、對數據進行刪除和修改:
4、用select查詢單個或多個數據信息:
5、去除重覆值:
6、查詢的各種用法:
between的用法:
查詢排序:
limit的用法:
分組:
查詢總數:
起別名:
select *from 表 where id = 2;
select * from 表 GROUP BY CLASS LIMIT 0,2;
select * from 表 where age > 30 order by chengji desc limit 5,5;
內聯:
select 表1.欄位 [as 別名],表n.欄位 from 表1 inner join 表2 on 條件;
select username,name from shop_user inner join shop_goods on shop_user.gid = shop_goods.gids;
說明:以上方式的inner關鍵字換成cross同樣可以,其實也可以省略
左鏈接:
以坐標為基準
select 表1.欄位 [as 別名],表n,欄位 from 表1 left join 表n on 條件;
select username,name as uname,name as gname from shop_user right join shop_goods on shop _user.gid = shop_goods.gid;
右鏈接:
select 表1.欄位 [as 別名],表n.欄位 from 表1 right join 表n on 條件;
select username as uname,name as gname from shop_user right join shop_goods on shop_user.gid = shop_goods.gid;
嵌套查詢:不推薦使用 效率慢
select 欄位 from 表 where 欄位 in(select id form 表);
select * from shop user where gid in (select gid from shop_goods);