ホームページ  >  記事  >  データベース  >  mysqlチェック

mysqlチェック

黄舟
黄舟オリジナル
2017-01-16 13:14:201052ブラウズ

テーブルの行数を取得します
ヒント:

select count(*) from table_name;


cat_id=4 と cat_id=11 の列を取得します
cat_id=4 または cat_id=11 の商品から * を使用または選択します;
* を使用または選択しないでくださいcat_id が (4,11) の商品から

価格を取り出します>=100 and778f8c8e80e0660a4fd5875d16d0d389=500

select * from goods where shop_price <=100 and shop_price >= 500;
select * from goods where shop_price not between 100 and 500;

in はスキャッターのセットです点、 と の間は間隔です

cat_idは3や11の列ではありません

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 ;

市場価格より200以上安い現地価格を見つけてください

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;(错误的)



(chajia列は後で生成される場所で使用されます)

疑問点の注: where は実際のテーブルのデータに対して機能し、where の結果をフィルタリングできます

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;

メインテーブルの num 列を [20, 29] を 20 に変更 [30,39] を 30 に変更

select goods_id ,goods_name,substring(goods_name,4) from goods where goods_name like &#39;诺基亚%&#39;;

ファジークエリのように


Nokia の後のコンテンツをインターセプト

select goods_id ,goods_name,concat(&#39;htc&#39;,substring(goods_name,4)) from goods where goods_name like &#39;诺基亚%&#39;;

Nokia で始まるコンテンツを検索htc に置き換えます (実際のテーブルの内容は変更しません)

update goods 
set goods_name = concat(&#39;htc&#39;,substring(goods_name,4))
where goods_name like &#39;诺基亚%&#39; and cat_id=4;

Nokia を htc に置き換えます (実際のテーブルの内容は変更します)


rrreee

上記は mysql チェックの内容です。 PHP 中国語 Web サイト (www.php.cn) にアクセスしてください。 🎜🎜🎜🎜
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。