>  기사  >  데이터 베이스  >  MySQL의 확인

MySQL의 확인

黄舟
黄舟원래의
2017-01-16 13:14:201055검색

테이블에 있는 행 수 확인
팁:

select count(*) from table_name;


cat_id=4 및 cat_id=11로 열 가져오기
cat_id=인 상품에서 *를 사용하거나 선택하세요. 4 또는 cat_id=11 ;
cat_id가 (4,11)인 상품에서 *를 사용하거나 선택하지 마세요.

가격 확인>=100 및2cfd3aa7e372e0a98912f4ba038e5bec=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;



(chajia 열은 where가 사용된 후에 생성됩니다.)

의심스러운 참고: where는 실제 테이블의 데이터에 대해 작동하며, where 결과 필터링

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;

메인 테이블의 num 열에서 [20,29]를 20[30,39]로 변경합니다. ] ~ 30

update mian set num = floor(num/10)*10 where num between 20 and 39;

like fuzzy query

Nokia 이후의 콘텐츠 가로채기

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

Nokia로 시작하는 콘텐츠를 찾아서 htc로 대체(no 실제 테이블 내용으로 변경)

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;

위는 mysql 확인 내용입니다. 내용은 PHP 중국어 홈페이지(www.php.cn)를 주목해주세요!


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.