mysql鐨勫鍒犳敼鏌ヨ繘闃剁増
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql鐨勫鍒犳敼鏌ヨ繘闃剁増相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e6%a8%a1%e7%b3%8a' title='妯$硦'>妯$硦
鎺掑簭 鍑芥暟 asc 鍒嗛〉鏌ヨ mys 鍒嗙粍鏌ヨ 娌℃湁 select姣忔棩鎬荤粨
妯$硦鏌ヨlike
select * from 琛ㄥ悕 where 瀛楁 like ‘%w%’;
%:琛ㄧず浠绘剰瀛楃锛涘繀椤昏鍐欏湪寮曞彿閲岄潰锛屽鏋滃悗杈规病鏈?璇存槑w鍚庨潰涓嶄細鏈夊瓧绗︺€傚弽涔嬩害鐒?br />select * from 琛ㄥ悕 where 瀛楁 like ‘鏉巁’;
_:琛ㄧず涓€涓瓧绗︼紱蹇呴』瑕佸啓鍦ㄥ紩鍙烽噷闈紝濡傛灉鍚庤竟鏈塤浠h〃蹇呴』鏈変竴涓瓧绗︼紝鍙嶄箣浜︾劧
鎺掑簭(order by)锛屽彲浠ュ瀛楁鎺掑簭
select *from 琛ㄥ悕 order by 鍒楀悕 asc锛坅sc鍗囧簭榛樿锛沝esc闄嶅簭锛?br />鑱氬悎鍑芥暟鏌ヨ
min鏈€灏忓€?max鏈€澶у€?sum鍊肩殑鍜?count缁熻琛屾暟;avg骞冲眬鍊?br />鍒嗙粍鏌ヨ:
group by
璁℃暟鍊硷細 count(瀛楁)锛?琛ㄧず姹傚嚭涓€缁勪腑鍘熷鏁版嵁鐨勮鏁帮紱
鏈€澶у€硷細 max(瀛楁)锛岃〃绀烘眰鍑轰竴缁勪腑璇ュ瓧娈电殑鏈€澶у€硷紱
鏈€灏忓€硷細 min(瀛楁)锛岃〃绀烘眰鍑轰竴缁勪腑璇ュ瓧娈电殑鏈€灏忓€硷紱
骞冲潎鍊硷細 avg(瀛楁)锛岃〃绀烘眰鍑轰竴缁勪腑璇ュ瓧娈电殑骞冲潎鍊硷紱
鎬诲拰鍊硷細 sum(瀛楁)锛岃〃绀烘眰鍑轰竴缁勪腑璇ュ瓧娈电殑绱姞鍜岋紱
鍒嗛〉鏌ヨ
limit 璧峰琛?琛屾暟;
澶氳〃鑱斿悎鏌ヨ
join on
select * from 琛? as a join 琛? as b on a.id=b.lid where a.id =3;
left join
right join
淇勭綏鏂濞?br />select * from teacher where id =(select tid from grade group by tid order by count(*) desc limit 0,1);
鍦ㄦ煡璇腑鍙互鍏堟煡璇竴涓潯浠讹紝鐒跺悗鍐嶇敤where鎶婂畠濂椾綇锛屼綔涓轰竴涓獁here鐨刬d锛涘彲浠ュ弽澶嶅锛?/p>
以上是关于mysql鐨勫鍒犳敼鏌ヨ繘闃剁増的主要内容,如果未能解决你的问题,请参考以下文章
濡備綍灏嗘暟鎹粠MySQL/MongoDB涓縼绉昏嚦浜戝紑鍙戞暟鎹簱
mysql 瑙﹀彂鍣ㄥ疄鐜扮骇鑱斿垹闄ゆ湁澶栭敭鐨勫寮犺〃