獲取表格有多少行
技巧:
select count(*) from table_name;
取出cat_id=4和cat_id=11的列
使用or select * from goods where cat_id=4 or cat_id=11;
不使用or select * good (4,11);
取出價格>=100 且<=500
select * from goods where shop_price >= 100 and shop_price <= 500; select * from goods where shop_price between 100 and 500;
取出價格<=100 且>=500
select * from goods where shop_price <=100 and shop_price >= 500; select * from goods where shop_price not between 100 and 500;
in是散點的集合,between and
select * from goods where cat_id!=3 and cat_id!=11; select * from goods where cat_id not in(3,11);
select goods_id,(market_price-shop_price) as chajia ,goods_name from goods ;
select goods_id,(market_price-shop_price) as chajia ,goods_name from goods where (market_price - shop_price) > 200;
select goods_id,(market_price-shop_price) as chajia ,goods_name from goods where chajia > 200;(错误的)
select goods_id,(market_price-shop_price) as chajia ,goods_name from goods having chajia>200;
update mian set num = floor(num/10)*10 where num between 20 and 39;
select goods_id ,goods_name,substring(goods_name,4) from goods where goods_name like '诺基亚%';
select goods_id ,goods_name,concat('htc',substring(goods_name,4)) from goods where goods_name like '诺基亚%';
update goods set goods_name = concat('htc',substring(goods_name,4)) where goods_name like '诺基亚%' and cat_id=4;
以上就是mysql 查的內容,更多相關內容請關注PHP中文網(www.php.cn)!