1.0 刪除數(shù)據(jù)庫中的某個數(shù)據(jù)庫
drop database database_name
2.0 刪除數(shù)據(jù)庫中的某個表
drop table table_name
3.0 刪除數(shù)據(jù)庫中的表全部的內容
delete from table_name;
4.0 刪除數(shù)據(jù)庫中某個表的某一條內容
delete from table_name where ziduan=1;
5.0更新某一條數(shù)據(jù)
UPDATE 表名稱 SET 列名稱 = 新值 WHERE 列名稱 = 某值
6.0 在某個值等與不同值時蝌以,出現(xiàn)的次數(shù)
select type,count(*) from ims_ewei_shop_goods group by type;
//type等于不同值時焙压,出現(xiàn)的次數(shù)
7.0某個字段的總和
select sum(id) from ims_ewei_shop_goods
//在商品表中id的和
//若在后面加上group by 則根據(jù)某個分組求中某個和吵聪。例如一個訂單表中,同一個商品賣出的總是和
8.0group by 時 某些字段進行合并
6c57bb2e765554b05dcbd94ce8fd2e7.png
前
GROUP_CONCAT(想要合并 的字段);
#實例:將goodsid進行group by ,其他重要字段合并到一起
select a.goodsid,a.titles,b.title,a.stock,a.presellprice,a.marketprice,a.marketprice,a.productprice,a.costprice,a
.goodssn,a.productsn,a.weight,b.id,b.status,b.unit,b.type,b.nocommission,b.isverify from (select
goodsid,GROUP_CONCAT(title) as titles,GROUP_CONCAT(stock) as
stock,GROUP_CONCAT(presellprice) as presellprice,GROUP_CONCAT(marketprice) as
marketprice,GROUP_CONCAT(productprice) as productprice,GROUP_CONCAT(costprice) as
costprice,GROUP_CONCAT(goodssn) as goodssn,GROUP_CONCAT(productsn) as
productsn,GROUP_CONCAT(weight) as weight from ims_ewei_shop_goods_option where goodssn
like '%mm%' GROUP BY goodsid ) as a left join ims_ewei_shop_goods as b on b.id=a.goodsid
bc356a2edd5fe311b66cc7246bb25d3.png
后