{"id":106765,"date":"2026-09-18T09:48:59","date_gmt":"2026-09-18T01:48:59","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/106765.html"},"modified":"2026-09-18T09:48:59","modified_gmt":"2026-09-18T01:48:59","slug":"mysql-dql%e5%85%a8%e9%9d%a2%e8%a7%a3%e6%9e%90%ef%bc%9a%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e7%b2%be%e9%80%9a","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/106765.html","title":{"rendered":"MySQL DQL\u5168\u9762\u89e3\u6790\uff1a\u4ece\u5165\u95e8\u5230\u7cbe\u901a"},"content":{"rendered":"<p>\u200b<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260918014857-6aac9889ceeac.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5728\u6570\u636e\u5e93\u7684\u5e7f\u9614\u5929\u5730\u4e2d&#xff0c;MySQL \u51ed\u501f\u5176\u5f00\u6e90\u3001\u9ad8\u6548\u3001\u6613\u7528\u7b49\u7279\u6027&#xff0c;\u6210\u4e3a\u4e86\u4f17\u591a\u5f00\u53d1\u8005\u7684\u9996\u9009\u3002\u800c\u5728 MySQL \u7684\u4f17\u591a\u529f\u80fd\u4e2d&#xff0c;\u6570\u636e\u67e5\u8be2\u8bed\u8a00&#xff08;Data Query Language&#xff0c;\u7b80\u79f0 DQL&#xff09;\u65e0\u7591\u662f\u6700\u4e3a\u5e38\u7528\u4e14\u5f3a\u5927\u7684\u90e8\u5206\u4e4b\u4e00\u3002\u901a\u8fc7 DQL&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4ece\u6570\u636e\u5e93\u4e2d\u68c0\u7d22\u51fa\u6240\u9700\u7684\u6570\u636e&#xff0c;\u8fdb\u884c\u5404\u79cd\u590d\u6742\u7684\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8 MySQL DQL \u7684\u5404\u4e2a\u65b9\u9762&#xff0c;\u5e2e\u52a9\u4f60\u5168\u9762\u638c\u63e1\u8fd9\u4e00\u91cd\u8981\u6280\u80fd\u3002<\/p>\n<h4>\u4e00\u3001DQL \u57fa\u7840&#xff1a;SELECT \u8bed\u53e5\u5165\u95e8<\/h4>\n<p>DQL \u7684\u6838\u5fc3\u662f SELECT \u8bed\u53e5&#xff0c;\u5b83\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> column1<span class=\"token punctuation\">,<\/span> column2<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><br \/>\n<span class=\"token keyword\">FROM<\/span> table_name<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5176\u4e2d&#xff0c;SELECT\u5173\u952e\u5b57\u6307\u5b9a\u8981\u67e5\u8be2\u7684\u5217&#xff0c;FROM\u5173\u952e\u5b57\u6307\u5b9a\u6570\u636e\u6765\u6e90\u7684\u8868\u3002\u4f8b\u5982&#xff0c;\u5047\u8bbe\u6709\u4e00\u4e2a\u540d\u4e3aemployees\u7684\u8868&#xff0c;\u5305\u542bemployee_id\u3001first_name\u3001last_name\u548csalary\u7b49\u5217&#xff0c;\u8981\u67e5\u8be2\u6240\u6709\u5458\u5de5\u7684\u59d3\u540d\u548c\u85aa\u6c34&#xff0c;\u53ef\u4ee5\u8fd9\u6837\u5199&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> first_name<span class=\"token punctuation\">,<\/span> last_name<span class=\"token punctuation\">,<\/span> salary<br \/>\n<span class=\"token keyword\">FROM<\/span> employees<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5982\u679c\u8981\u67e5\u8be2\u8868\u4e2d\u7684\u6240\u6709\u5217&#xff0c;\u53ef\u4ee5\u4f7f\u7528\u901a\u914d\u7b26*&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token operator\">*<\/span><br \/>\n<span class=\"token keyword\">FROM<\/span> employees<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4e0d\u8fc7&#xff0c;\u5728\u5b9e\u9645\u5e94\u7528\u4e2d&#xff0c;\u5c3d\u91cf\u660e\u786e\u6307\u5b9a\u6240\u9700\u5217&#xff0c;\u8fd9\u6837\u4e0d\u4ec5\u53ef\u4ee5\u63d0\u9ad8\u67e5\u8be2\u6548\u7387&#xff0c;\u8fd8\u80fd\u4f7f\u4ee3\u7801\u66f4\u5177\u53ef\u8bfb\u6027\u3002<\/p>\n<h4>\u4e8c\u3001\u6570\u636e\u8fc7\u6ee4&#xff1a;WHERE \u5b50\u53e5\u7684\u4f7f\u7528<\/h4>\n<p>\u5728\u5f88\u591a\u60c5\u51b5\u4e0b&#xff0c;\u6211\u4eec\u5e76\u4e0d\u9700\u8981\u67e5\u8be2\u8868\u4e2d\u7684\u6240\u6709\u6570\u636e&#xff0c;\u800c\u662f\u5e0c\u671b\u6839\u636e\u7279\u5b9a\u6761\u4ef6\u8fdb\u884c\u7b5b\u9009\u3002\u8fd9\u65f6&#xff0c;\u5c31\u9700\u8981\u7528\u5230WHERE\u5b50\u53e5\u3002WHERE\u5b50\u53e5\u7528\u4e8e\u5728SELECT\u8bed\u53e5\u4e2d\u6dfb\u52a0\u6761\u4ef6&#xff0c;\u8fc7\u6ee4\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u884c\u3002\u5176\u8bed\u6cd5\u5982\u4e0b&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> column1<span class=\"token punctuation\">,<\/span> column2<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> table_name<\/p>\n<p><span class=\"token keyword\">WHERE<\/span> condition<span class=\"token punctuation\">;<\/span><\/p>\n<p>condition\u662f\u4e00\u4e2a\u903b\u8f91\u8868\u8fbe\u5f0f&#xff0c;\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u6bd4\u8f83\u8fd0\u7b97\u7b26&#xff08;\u5982&#061;\u3001&lt;&gt;\u3001&lt;\u3001&gt;\u3001&lt;&#061;\u3001&gt;&#061;&#xff09;\u3001\u903b\u8f91\u8fd0\u7b97\u7b26&#xff08;\u5982AND\u3001OR\u3001NOT&#xff09;\u4ee5\u53ca\u5176\u4ed6\u51fd\u6570\u548c\u8868\u8fbe\u5f0f\u3002\u4f8b\u5982&#xff0c;\u8981\u67e5\u8be2\u85aa\u6c34\u5927\u4e8e 5000 \u7684\u5458\u5de5\u4fe1\u606f&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token operator\">*<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<\/p>\n<p><span class=\"token keyword\">WHERE<\/span> salary <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">5000<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8981\u67e5\u8be2\u90e8\u95e8\u4e3a \u201c\u9500\u552e\u90e8\u201d \u4e14\u85aa\u6c34\u5927\u4e8e 8000 \u7684\u5458\u5de5&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token operator\">*<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<\/p>\n<p><span class=\"token keyword\">WHERE<\/span> department <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;\u9500\u552e\u90e8&#039;<\/span> <span class=\"token operator\">AND<\/span> salary <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">8000<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>WHERE\u5b50\u53e5\u8fd8\u652f\u6301\u4f7f\u7528LIKE\u5173\u952e\u5b57\u8fdb\u884c\u6a21\u7cca\u67e5\u8be2\u3002LIKE\u901a\u5e38\u4e0e\u901a\u914d\u7b26\u4e00\u8d77\u4f7f\u7528&#xff0c;%\u8868\u793a\u4efb\u610f\u5b57\u7b26\u5e8f\u5217&#xff08;\u5305\u62ec\u7a7a\u5b57\u7b26\u5e8f\u5217&#xff09;&#xff0c;_\u8868\u793a\u4efb\u610f\u5355\u4e2a\u5b57\u7b26\u3002\u4f8b\u5982&#xff0c;\u8981\u67e5\u8be2\u59d3 \u201c\u5f20\u201d \u7684\u5458\u5de5&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token operator\">*<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<\/p>\n<p><span class=\"token keyword\">WHERE<\/span> first_name <span class=\"token operator\">LIKE<\/span> <span class=\"token string\">&#039;\u5f20%&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u67e5\u8be2\u540d\u5b57\u4e2d\u5305\u542b \u201c\u660e\u201d \u5b57\u7684\u5458\u5de5&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token operator\">*<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<\/p>\n<p><span class=\"token keyword\">WHERE<\/span> first_name <span class=\"token operator\">LIKE<\/span> <span class=\"token string\">&#039;%\u660e%&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h4>\u4e09\u3001\u7ed3\u679c\u6392\u5e8f&#xff1a;ORDER BY \u5b50\u53e5<\/h4>\n<p>\u67e5\u8be2\u7ed3\u679c\u9ed8\u8ba4\u662f\u65e0\u5e8f\u7684&#xff0c;\u4f46\u5728\u5b9e\u9645\u5e94\u7528\u4e2d&#xff0c;\u6211\u4eec\u5e38\u5e38\u9700\u8981\u5bf9\u7ed3\u679c\u8fdb\u884c\u6392\u5e8f&#xff0c;\u4ee5\u4fbf\u66f4\u597d\u5730\u67e5\u770b\u548c\u5206\u6790\u6570\u636e\u3002ORDER BY\u5b50\u53e5\u7528\u4e8e\u5bf9\u67e5\u8be2\u7ed3\u679c\u8fdb\u884c\u6392\u5e8f&#xff0c;\u5176\u8bed\u6cd5\u5982\u4e0b&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> column1<span class=\"token punctuation\">,<\/span> column2<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> table_name<\/p>\n<p><span class=\"token keyword\">ORDER<\/span> <span class=\"token keyword\">BY<\/span> column1 <span class=\"token punctuation\">[<\/span><span class=\"token keyword\">ASC<\/span><span class=\"token operator\">|<\/span><span class=\"token keyword\">DESC<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> column2 <span class=\"token punctuation\">[<\/span><span class=\"token keyword\">ASC<\/span><span class=\"token operator\">|<\/span><span class=\"token keyword\">DESC<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>ASC\u8868\u793a\u5347\u5e8f\u6392\u5217&#xff08;\u9ed8\u8ba4&#xff09;&#xff0c;DESC\u8868\u793a\u964d\u5e8f\u6392\u5217\u3002\u4f8b\u5982&#xff0c;\u8981\u6309\u7167\u85aa\u6c34\u4ece\u9ad8\u5230\u4f4e\u67e5\u8be2\u5458\u5de5\u4fe1\u606f&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token operator\">*<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<\/p>\n<p><span class=\"token keyword\">ORDER<\/span> <span class=\"token keyword\">BY<\/span> salary <span class=\"token keyword\">DESC<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5982\u679c\u8981\u5148\u6309\u90e8\u95e8\u5347\u5e8f\u6392\u5e8f&#xff0c;\u5728\u6bcf\u4e2a\u90e8\u95e8\u5185\u518d\u6309\u85aa\u6c34\u964d\u5e8f\u6392\u5e8f&#xff0c;\u53ef\u4ee5\u8fd9\u6837\u5199&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token operator\">*<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<\/p>\n<p><span class=\"token keyword\">ORDER<\/span> <span class=\"token keyword\">BY<\/span> department <span class=\"token keyword\">ASC<\/span><span class=\"token punctuation\">,<\/span> salary <span class=\"token keyword\">DESC<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h4>\u56db\u3001\u805a\u5408\u51fd\u6570&#xff1a;\u7edf\u8ba1\u6570\u636e\u7684\u5229\u5668<\/h4>\n<p>\u805a\u5408\u51fd\u6570\u7528\u4e8e\u5bf9\u4e00\u7ec4\u6570\u636e\u8fdb\u884c\u8ba1\u7b97&#xff0c;\u5e76\u8fd4\u56de\u4e00\u4e2a\u5355\u4e00\u7684\u503c\u3002\u5e38\u89c1\u7684\u805a\u5408\u51fd\u6570\u6709COUNT&#xff08;\u8ba1\u6570&#xff09;\u3001SUM&#xff08;\u6c42\u548c&#xff09;\u3001AVG&#xff08;\u5e73\u5747\u503c&#xff09;\u3001MAX&#xff08;\u6700\u5927\u503c&#xff09;\u548cMIN&#xff08;\u6700\u5c0f\u503c&#xff09;\u3002\u8fd9\u4e9b\u51fd\u6570\u5728\u6570\u636e\u5206\u6790\u4e2d\u975e\u5e38\u6709\u7528\u3002<\/p>\n<li>COUNT \u51fd\u6570&#xff1a;\u7528\u4e8e\u7edf\u8ba1\u6ee1\u8db3\u6761\u4ef6\u7684\u884c\u6570\u3002\u4f8b\u5982&#xff0c;\u8981\u7edf\u8ba1\u5458\u5de5\u8868\u4e2d\u7684\u5458\u5de5\u603b\u6570&#xff1a;<\/li>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token function\">COUNT<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8981\u7edf\u8ba1\u85aa\u6c34\u5927\u4e8e 6000 \u7684\u5458\u5de5\u4eba\u6570&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token function\">COUNT<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<\/p>\n<p><span class=\"token keyword\">WHERE<\/span> salary <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">6000<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<li>SUM \u51fd\u6570&#xff1a;\u7528\u4e8e\u8ba1\u7b97\u67d0\u4e00\u5217\u7684\u603b\u548c\u3002\u4f8b\u5982&#xff0c;\u8981\u8ba1\u7b97\u6240\u6709\u5458\u5de5\u7684\u85aa\u6c34\u603b\u548c&#xff1a;<\/li>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token function\">SUM<\/span><span class=\"token punctuation\">(<\/span>salary<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<span class=\"token punctuation\">;<\/span><\/p>\n<li>AVG \u51fd\u6570&#xff1a;\u7528\u4e8e\u8ba1\u7b97\u67d0\u4e00\u5217\u7684\u5e73\u5747\u503c\u3002\u4f8b\u5982&#xff0c;\u8981\u8ba1\u7b97\u5458\u5de5\u7684\u5e73\u5747\u85aa\u6c34&#xff1a;<\/li>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token function\">AVG<\/span><span class=\"token punctuation\">(<\/span>salary<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<span class=\"token punctuation\">;<\/span><\/p>\n<li>MAX \u548c MIN \u51fd\u6570&#xff1a;\u5206\u522b\u7528\u4e8e\u83b7\u53d6\u67d0\u4e00\u5217\u7684\u6700\u5927\u503c\u548c\u6700\u5c0f\u503c\u3002\u4f8b\u5982&#xff0c;\u8981\u83b7\u53d6\u6700\u9ad8\u85aa\u6c34\u548c\u6700\u4f4e\u85aa\u6c34&#xff1a;<\/li>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token function\">MAX<\/span><span class=\"token punctuation\">(<\/span>salary<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">MIN<\/span><span class=\"token punctuation\">(<\/span>salary<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4e94\u3001\u5206\u7ec4\u67e5\u8be2&#xff1a;GROUP BY \u5b50\u53e5\u4e0e HAVING \u5b50\u53e5<\/p>\n<p>\u5f53\u6211\u4eec\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u5206\u7ec4\u7edf\u8ba1\u65f6&#xff0c;\u5c31\u9700\u8981\u7528\u5230GROUP BY\u5b50\u53e5\u3002GROUP BY\u5b50\u53e5\u5c06\u67e5\u8be2\u7ed3\u679c\u6309\u7167\u6307\u5b9a\u7684\u5217\u8fdb\u884c\u5206\u7ec4&#xff0c;\u7136\u540e\u53ef\u4ee5\u5bf9\u6bcf\u4e2a\u7ec4\u5e94\u7528\u805a\u5408\u51fd\u6570\u3002\u5176\u8bed\u6cd5\u5982\u4e0b&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> column1<span class=\"token punctuation\">,<\/span> aggregate_function<span class=\"token punctuation\">(<\/span>column2<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> table_name<\/p>\n<p><span class=\"token keyword\">GROUP<\/span> <span class=\"token keyword\">BY<\/span> column1<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4f8b\u5982&#xff0c;\u8981\u6309\u90e8\u95e8\u7edf\u8ba1\u5458\u5de5\u4eba\u6570&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> department<span class=\"token punctuation\">,<\/span> <span class=\"token function\">COUNT<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<\/p>\n<p><span class=\"token keyword\">GROUP<\/span> <span class=\"token keyword\">BY<\/span> department<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5982\u679c\u5728\u5206\u7ec4\u540e\u8fd8\u9700\u8981\u5bf9\u7ec4\u8fdb\u884c\u8fc7\u6ee4&#xff0c;\u5c31\u9700\u8981\u4f7f\u7528HAVING\u5b50\u53e5\u3002HAVING\u5b50\u53e5\u7684\u4f5c\u7528\u7c7b\u4f3c\u4e8eWHERE\u5b50\u53e5&#xff0c;\u4f46WHERE\u5b50\u53e5\u7528\u4e8e\u5bf9\u884c\u8fdb\u884c\u8fc7\u6ee4&#xff0c;\u800cHAVING\u5b50\u53e5\u7528\u4e8e\u5bf9\u7ec4\u8fdb\u884c\u8fc7\u6ee4\u3002\u4f8b\u5982&#xff0c;\u8981\u67e5\u8be2\u5458\u5de5\u4eba\u6570\u5927\u4e8e 5 \u7684\u90e8\u95e8&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> department<span class=\"token punctuation\">,<\/span> <span class=\"token function\">COUNT<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<\/p>\n<p><span class=\"token keyword\">GROUP<\/span> <span class=\"token keyword\">BY<\/span> department<\/p>\n<p><span class=\"token keyword\">HAVING<\/span> <span class=\"token function\">COUNT<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">5<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h4>\u516d\u3001\u8fde\u63a5\u67e5\u8be2&#xff1a;\u6574\u5408\u591a\u8868\u6570\u636e<\/h4>\n<p>\u5728\u5b9e\u9645\u7684\u6570\u636e\u5e93\u5e94\u7528\u4e2d&#xff0c;\u6570\u636e\u5f80\u5f80\u5206\u6563\u5728\u591a\u4e2a\u8868\u4e2d\u3002\u8fde\u63a5\u67e5\u8be2\u5141\u8bb8\u6211\u4eec\u4ece\u591a\u4e2a\u8868\u4e2d\u68c0\u7d22\u6570\u636e&#xff0c;\u5e76\u5c06\u5b83\u4eec\u7ec4\u5408\u5728\u4e00\u8d77\u3002\u5e38\u89c1\u7684\u8fde\u63a5\u7c7b\u578b\u6709\u5185\u8fde\u63a5&#xff08;INNER JOIN&#xff09;\u3001\u5de6\u8fde\u63a5&#xff08;LEFT JOIN&#xff09;\u3001\u53f3\u8fde\u63a5&#xff08;RIGHT JOIN&#xff09;\u548c\u5168\u8fde\u63a5&#xff08;FULL JOIN&#xff0c;MySQL \u4e0d\u76f4\u63a5\u652f\u6301&#xff0c;\u53ef\u901a\u8fc7LEFT JOIN\u548cRIGHT JOIN\u8054\u5408\u5b9e\u73b0&#xff09;\u3002<\/p>\n<li>\u5185\u8fde\u63a5&#xff08;INNER JOIN&#xff09;&#xff1a;\u8fd4\u56de\u4e24\u4e2a\u8868\u4e2d\u6ee1\u8db3\u8fde\u63a5\u6761\u4ef6\u7684\u6240\u6709\u884c\u3002\u5176\u8bed\u6cd5\u5982\u4e0b&#xff1a;<\/li>\n<p><span class=\"token keyword\">SELECT<\/span> column1<span class=\"token punctuation\">,<\/span> column2<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> table1<\/p>\n<p><span class=\"token keyword\">INNER<\/span> <span class=\"token keyword\">JOIN<\/span> table2<\/p>\n<p><span class=\"token keyword\">ON<\/span> table1<span class=\"token punctuation\">.<\/span>common_column <span class=\"token operator\">&#061;<\/span> table2<span class=\"token punctuation\">.<\/span>common_column<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4f8b\u5982&#xff0c;\u5047\u8bbe\u6709\u4e00\u4e2adepartments\u8868&#xff0c;\u5305\u542bdepartment_id\u548cdepartment_name\u5217&#xff0c;\u8981\u67e5\u8be2\u6bcf\u4e2a\u90e8\u95e8\u53ca\u5176\u5458\u5de5\u4fe1\u606f&#xff0c;\u53ef\u4ee5\u4f7f\u7528\u5185\u8fde\u63a5&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> employees<span class=\"token punctuation\">.<\/span>employee_id<span class=\"token punctuation\">,<\/span> employees<span class=\"token punctuation\">.<\/span>first_name<span class=\"token punctuation\">,<\/span> departments<span class=\"token punctuation\">.<\/span>department_name<\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<\/p>\n<p><span class=\"token keyword\">INNER<\/span> <span class=\"token keyword\">JOIN<\/span> departments<\/p>\n<p><span class=\"token keyword\">ON<\/span> employees<span class=\"token punctuation\">.<\/span>department_id <span class=\"token operator\">&#061;<\/span> departments<span class=\"token punctuation\">.<\/span>department_id<span class=\"token punctuation\">;<\/span><\/p>\n<li>\u5de6\u8fde\u63a5&#xff08;LEFT JOIN&#xff09;&#xff1a;\u8fd4\u56de\u5de6\u8868\u4e2d\u7684\u6240\u6709\u884c\u4ee5\u53ca\u53f3\u8868\u4e2d\u6ee1\u8db3\u8fde\u63a5\u6761\u4ef6\u7684\u884c\u3002\u5982\u679c\u53f3\u8868\u4e2d\u6ca1\u6709\u5339\u914d\u7684\u884c&#xff0c;\u5219\u7ed3\u679c\u96c6\u4e2d\u76f8\u5e94\u5217\u7684\u503c\u4e3aNULL\u3002\u8bed\u6cd5\u5982\u4e0b&#xff1a;<\/li>\n<p><span class=\"token keyword\">SELECT<\/span> column1<span class=\"token punctuation\">,<\/span> column2<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> table1<\/p>\n<p><span class=\"token keyword\">LEFT<\/span> <span class=\"token keyword\">JOIN<\/span> table2<\/p>\n<p><span class=\"token keyword\">ON<\/span> table1<span class=\"token punctuation\">.<\/span>common_column <span class=\"token operator\">&#061;<\/span> table2<span class=\"token punctuation\">.<\/span>common_column<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4f8b\u5982&#xff0c;\u8981\u67e5\u8be2\u6240\u6709\u90e8\u95e8\u53ca\u5176\u5458\u5de5\u4fe1\u606f&#xff0c;\u5373\u4f7f\u67d0\u4e2a\u90e8\u95e8\u6ca1\u6709\u5458\u5de5&#xff0c;\u4e5f\u8981\u663e\u793a\u8be5\u90e8\u95e8\u4fe1\u606f&#xff0c;\u53ef\u4ee5\u4f7f\u7528\u5de6\u8fde\u63a5&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> departments<span class=\"token punctuation\">.<\/span>department_name<span class=\"token punctuation\">,<\/span> employees<span class=\"token punctuation\">.<\/span>employee_id<span class=\"token punctuation\">,<\/span> employees<span class=\"token punctuation\">.<\/span>first_name<\/p>\n<p><span class=\"token keyword\">FROM<\/span> departments<\/p>\n<p><span class=\"token keyword\">LEFT<\/span> <span class=\"token keyword\">JOIN<\/span> employees<\/p>\n<p><span class=\"token keyword\">ON<\/span> departments<span class=\"token punctuation\">.<\/span>department_id <span class=\"token operator\">&#061;<\/span> employees<span class=\"token punctuation\">.<\/span>department_id<span class=\"token punctuation\">;<\/span><\/p>\n<li>\u53f3\u8fde\u63a5&#xff08;RIGHT JOIN&#xff09;&#xff1a;\u4e0e\u5de6\u8fde\u63a5\u76f8\u53cd&#xff0c;\u8fd4\u56de\u53f3\u8868\u4e2d\u7684\u6240\u6709\u884c\u4ee5\u53ca\u5de6\u8868\u4e2d\u6ee1\u8db3\u8fde\u63a5\u6761\u4ef6\u7684\u884c\u3002\u8bed\u6cd5\u5982\u4e0b&#xff1a;<\/li>\n<p><span class=\"token keyword\">SELECT<\/span> column1<span class=\"token punctuation\">,<\/span> column2<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> table1<\/p>\n<p><span class=\"token keyword\">RIGHT<\/span> <span class=\"token keyword\">JOIN<\/span> table2<\/p>\n<p><span class=\"token keyword\">ON<\/span> table1<span class=\"token punctuation\">.<\/span>common_column <span class=\"token operator\">&#061;<\/span> table2<span class=\"token punctuation\">.<\/span>common_column<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d&#xff0c;\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u8fde\u63a5\u7c7b\u578b\u975e\u5e38\u91cd\u8981&#xff0c;\u5b83\u76f4\u63a5\u5f71\u54cd\u5230\u67e5\u8be2\u7ed3\u679c\u7684\u51c6\u786e\u6027\u548c\u5b8c\u6574\u6027\u3002<\/p>\n<h4>\u4e03\u3001\u5b50\u67e5\u8be2&#xff1a;\u67e5\u8be2\u4e2d\u7684\u67e5\u8be2<\/h4>\n<p>\u5b50\u67e5\u8be2\u662f\u6307\u5728\u4e00\u4e2a\u67e5\u8be2\u8bed\u53e5\u4e2d\u5d4c\u5957\u53e6\u4e00\u4e2a\u67e5\u8be2\u8bed\u53e5\u3002\u5b50\u67e5\u8be2\u53ef\u4ee5\u5d4c\u5957\u5728SELECT\u3001FROM\u3001WHERE\u7b49\u5b50\u53e5\u4e2d&#xff0c;\u7528\u4e8e\u89e3\u51b3\u4e00\u4e9b\u590d\u6742\u7684\u67e5\u8be2\u9700\u6c42\u3002\u4f8b\u5982&#xff0c;\u8981\u67e5\u8be2\u85aa\u6c34\u9ad8\u4e8e\u5e73\u5747\u85aa\u6c34\u7684\u5458\u5de5&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token operator\">*<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<\/p>\n<p><span class=\"token keyword\">WHERE<\/span> salary <span class=\"token operator\">&gt;<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">SELECT<\/span> <span class=\"token function\">AVG<\/span><span class=\"token punctuation\">(<\/span>salary<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">FROM<\/span> employees<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d&#xff0c;\u5b50\u67e5\u8be2(SELECT AVG(salary) FROM employees)\u5148\u8ba1\u7b97\u51fa\u5e73\u5747\u85aa\u6c34&#xff0c;\u7136\u540e\u4e3b\u67e5\u8be2\u6839\u636e\u8fd9\u4e2a\u7ed3\u679c\u7b5b\u9009\u51fa\u85aa\u6c34\u9ad8\u4e8e\u5e73\u5747\u85aa\u6c34\u7684\u5458\u5de5\u3002<\/p>\n<p>\u5b50\u67e5\u8be2\u8fd8\u53ef\u4ee5\u7528\u4e8e\u591a\u8868\u5173\u8054\u7684\u590d\u6742\u67e5\u8be2\u573a\u666f\u3002\u4f8b\u5982&#xff0c;\u5047\u8bbe\u6709\u4e00\u4e2aorders\u8868\u8bb0\u5f55\u8ba2\u5355\u4fe1\u606f&#xff0c;\u5305\u542border_id\u3001customer_id\u548corder_amount\u5217&#xff0c;\u8981\u67e5\u8be2\u8d2d\u4e70\u91d1\u989d\u6700\u9ad8\u7684\u5ba2\u6237\u4fe1\u606f&#xff0c;\u53ef\u4ee5\u8fd9\u6837\u5199&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token operator\">*<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> customers<\/p>\n<p><span class=\"token keyword\">WHERE<\/span> customer_id <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">SELECT<\/span> customer_id<\/p>\n<p>                   <span class=\"token keyword\">FROM<\/span> orders<\/p>\n<p>                   <span class=\"token keyword\">ORDER<\/span> <span class=\"token keyword\">BY<\/span> order_amount <span class=\"token keyword\">DESC<\/span><\/p>\n<p>                   <span class=\"token keyword\">LIMIT<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u91cc&#xff0c;\u5b50\u67e5\u8be2\u5148\u627e\u51fa\u8d2d\u4e70\u91d1\u989d\u6700\u9ad8\u7684\u8ba2\u5355\u5bf9\u5e94\u7684\u5ba2\u6237 ID&#xff0c;\u7136\u540e\u4e3b\u67e5\u8be2\u6839\u636e\u8fd9\u4e2a ID \u67e5\u8be2\u5ba2\u6237\u4fe1\u606f\u3002<\/p>\n<h4>\u516b\u3001DQL \u5b9e\u6218\u6280\u5de7\u4e0e\u4f18\u5316<\/h4>\n<li>\u4f7f\u7528\u7d22\u5f15&#xff1a;\u7d22\u5f15\u662f\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u7684\u91cd\u8981\u624b\u6bb5\u3002\u5728\u7ecf\u5e38\u7528\u4e8e\u67e5\u8be2\u6761\u4ef6\u7684\u5217\u4e0a\u521b\u5efa\u7d22\u5f15&#xff0c;\u53ef\u4ee5\u663e\u8457\u52a0\u5feb\u67e5\u8be2\u901f\u5ea6\u3002\u4f8b\u5982&#xff0c;\u5982\u679c\u7ecf\u5e38\u6839\u636e\u5458\u5de5\u7684employee_id\u8fdb\u884c\u67e5\u8be2&#xff0c;\u53ef\u4ee5\u5728employee_id\u5217\u4e0a\u521b\u5efa\u7d22\u5f15&#xff1a;<\/li>\n<p><span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">INDEX<\/span> idx_employee_id <span class=\"token keyword\">ON<\/span> employees<span class=\"token punctuation\">(<\/span>employee_id<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4f46\u8981\u6ce8\u610f&#xff0c;\u7d22\u5f15\u5e76\u4e0d\u662f\u8d8a\u591a\u8d8a\u597d&#xff0c;\u8fc7\u591a\u7684\u7d22\u5f15\u4f1a\u589e\u52a0\u6570\u636e\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u7684\u65f6\u95f4&#xff0c;\u56e0\u4e3a\u6570\u636e\u5e93\u5728\u66f4\u65b0\u6570\u636e\u65f6&#xff0c;\u8fd8\u9700\u8981\u540c\u65f6\u66f4\u65b0\u7d22\u5f15\u3002<\/p>\n<p>2. \u907f\u514d\u5168\u8868\u626b\u63cf&#xff1a;\u5c3d\u91cf\u907f\u514d\u5728\u67e5\u8be2\u4e2d\u4f7f\u7528\u6ca1\u6709\u7d22\u5f15\u7684\u5217\u8fdb\u884c\u8fc7\u6ee4\u6761\u4ef6&#xff0c;\u4ee5\u514d\u5bfc\u81f4\u5168\u8868\u626b\u63cf\u3002\u4f8b\u5982&#xff0c;\u5982\u679cemployees\u8868\u7684email\u5217\u6ca1\u6709\u7d22\u5f15&#xff0c;\u800c\u67e5\u8be2\u8bed\u53e5\u4e3aSELECT * FROM employees WHERE email &#061; &#039;&#096;&#096;example&#064;example.com&#096;&#096;&#039;;&#xff0c;\u6570\u636e\u5e93\u5c31\u9700\u8981\u626b\u63cf\u6574\u4e2a\u8868\u6765\u67e5\u627e\u5339\u914d\u7684\u884c&#xff0c;\u8fd9\u5728\u6570\u636e\u91cf\u8f83\u5927\u65f6\u4f1a\u975e\u5e38\u8017\u65f6\u3002<\/p>\n<p>3. \u4f18\u5316\u5b50\u67e5\u8be2&#xff1a;\u5b50\u67e5\u8be2\u867d\u7136\u5f3a\u5927&#xff0c;\u4f46\u5982\u679c\u4f7f\u7528\u4e0d\u5f53&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6027\u80fd\u95ee\u9898\u3002\u5728\u4e00\u4e9b\u60c5\u51b5\u4e0b&#xff0c;\u53ef\u4ee5\u5c06\u5b50\u67e5\u8be2\u6539\u5199\u4e3a\u8fde\u63a5\u67e5\u8be2&#xff0c;\u4ee5\u63d0\u9ad8\u6027\u80fd\u3002\u4f8b\u5982&#xff0c;\u524d\u9762\u63d0\u5230\u7684\u67e5\u8be2\u85aa\u6c34\u9ad8\u4e8e\u5e73\u5747\u85aa\u6c34\u7684\u5458\u5de5\u7684\u4f8b\u5b50&#xff0c;\u4e5f\u53ef\u4ee5\u6539\u5199\u4e3a\u8fde\u63a5\u67e5\u8be2&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> e1<span class=\"token punctuation\">.<\/span><span class=\"token operator\">*<\/span><\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees e1<\/p>\n<p><span class=\"token keyword\">JOIN<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">SELECT<\/span> <span class=\"token function\">AVG<\/span><span class=\"token punctuation\">(<\/span>salary<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">AS<\/span> avg_salary <span class=\"token keyword\">FROM<\/span> employees<span class=\"token punctuation\">)<\/span> e2<\/p>\n<p><span class=\"token keyword\">ON<\/span> e1<span class=\"token punctuation\">.<\/span>salary <span class=\"token operator\">&gt;<\/span> e2<span class=\"token punctuation\">.<\/span>avg_salary<span class=\"token punctuation\">;<\/span><\/p>\n<li>\u5408\u7406\u4f7f\u7528\u4e34\u65f6\u8868\u548c\u89c6\u56fe&#xff1a;\u5728\u5904\u7406\u590d\u6742\u67e5\u8be2\u65f6&#xff0c;\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u4e34\u65f6\u8868\u548c\u89c6\u56fe\u3002\u4e34\u65f6\u8868\u7528\u4e8e\u5b58\u50a8\u4e2d\u95f4\u7ed3\u679c&#xff0c;\u5728\u9700\u8981\u591a\u6b21\u4f7f\u7528\u8fd9\u4e9b\u7ed3\u679c\u65f6&#xff0c;\u53ef\u4ee5\u51cf\u5c11\u91cd\u590d\u8ba1\u7b97\u3002\u89c6\u56fe\u5219\u53ef\u4ee5\u5c06\u590d\u6742\u7684\u67e5\u8be2\u5c01\u88c5\u8d77\u6765&#xff0c;\u65b9\u4fbf\u540e\u7eed\u5f15\u7528&#xff0c;\u540c\u65f6\u4e5f\u63d0\u9ad8\u4e86\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u4e00\u81f4\u6027\u3002\u4f8b\u5982&#xff0c;\u521b\u5efa\u4e00\u4e2a\u89c6\u56fe\u6765\u67e5\u8be2\u6bcf\u4e2a\u90e8\u95e8\u7684\u5458\u5de5\u4eba\u6570\u548c\u5e73\u5747\u85aa\u6c34&#xff1a;<\/li>\n<p><span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">VIEW<\/span> department_summary <span class=\"token keyword\">AS<\/span><\/p>\n<p><span class=\"token keyword\">SELECT<\/span> department<span class=\"token punctuation\">,<\/span> <span class=\"token function\">COUNT<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">AS<\/span> employee\\\\_count<span class=\"token punctuation\">,<\/span> <span class=\"token function\">AVG<\/span><span class=\"token punctuation\">(<\/span>salary<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">AS<\/span> avg_salary<\/p>\n<p><span class=\"token keyword\">FROM<\/span> employees<\/p>\n<p><span class=\"token keyword\">GROUP<\/span> <span class=\"token keyword\">BY<\/span> department<span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4e4b\u540e&#xff0c;\u53ef\u4ee5\u50cf\u67e5\u8be2\u666e\u901a\u8868\u4e00\u6837\u67e5\u8be2\u8fd9\u4e2a\u89c6\u56fe&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token operator\">*<\/span> <span class=\"token keyword\">FROM<\/span> department_summary<span class=\"token punctuation\">;<\/span><\/p>\n<h4>\u4e5d\u3001\u603b\u7ed3<\/h4>\n<p>MySQL DQL \u4f5c\u4e3a\u6570\u636e\u5e93\u67e5\u8be2\u7684\u6838\u5fc3\u5de5\u5177&#xff0c;\u5177\u6709\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u5f3a\u5927\u7684\u8868\u73b0\u529b\u3002\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd&#xff0c;\u4f60\u5df2\u7ecf\u4e86\u89e3\u4e86 DQL \u7684\u57fa\u7840\u8bed\u6cd5\u3001\u5e38\u7528\u5b50\u53e5\u3001\u9ad8\u7ea7\u5e94\u7528\u4ee5\u53ca\u5b9e\u6218\u4f18\u5316\u6280\u5de7\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d&#xff0c;\u4e0d\u65ad\u7ec3\u4e60\u548c\u79ef\u7d2f\u7ecf\u9a8c&#xff0c;\u6839\u636e\u5177\u4f53\u7684\u4e1a\u52a1\u9700\u6c42\u7075\u6d3b\u8fd0\u7528\u8fd9\u4e9b\u77e5\u8bc6&#xff0c;\u4f60\u5c06\u80fd\u591f\u9ad8\u6548\u5730\u4ece\u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u6240\u9700\u7684\u6570\u636e&#xff0c;\u4e3a\u6570\u636e\u5206\u6790\u3001\u4e1a\u52a1\u51b3\u7b56\u7b49\u63d0\u4f9b\u6709\u529b\u652f\u6301\u3002<\/p>\n<p>\u5e0c\u671b\u672c\u6587\u80fd\u6210\u4e3a\u4f60\u5b66\u4e60 MySQL DQL \u7684\u5f97\u529b\u52a9\u624b&#xff0c;\u5e2e\u52a9\u4f60\u5728\u6570\u636e\u5e93\u5f00\u53d1\u7684\u9053\u8def\u4e0a\u8fc8\u51fa\u575a\u5b9e\u7684\u6b65\u4f10\u3002\u5982\u679c\u4f60\u5728\u5b66\u4e60\u8fc7\u7a0b\u4e2d\u9047\u5230\u95ee\u9898&#xff0c;\u4e0d\u8981\u6c14\u9981&#xff0c;\u591a\u67e5\u9605\u8d44\u6599&#xff0c;\u591a\u5b9e\u8df5&#xff0c;\u76f8\u4fe1\u4f60\u4e00\u5b9a\u80fd\u591f\u638c\u63e1\u8fd9\u95e8\u91cd\u8981\u7684\u6280\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u200b<br \/>\n\u5728\u6570\u636e\u5e93\u7684\u5e7f\u9614\u5929\u5730\u4e2d&#xff0c;MySQL \u51ed\u501f\u5176\u5f00\u6e90\u3001\u9ad8\u6548\u3001\u6613\u7528\u7b49\u7279\u6027&#xff0c;\u6210\u4e3a\u4e86\u4f17\u591a\u5f00\u53d1\u8005\u7684\u9996\u9009\u3002\u800c\u5728 MySQL \u7684\u4f17\u591a\u529f\u80fd\u4e2d&#xff0c;\u6570\u636e\u67e5\u8be2\u8bed\u8a00&#xff08;Data Query Language&#xff0c;\u7b80\u79f0 DQL&#xff09;\u65e0\u7591\u662f\u6700\u4e3a\u5e38\u7528\u4e14\u5f3a\u5927\u7684\u90e8\u5206\u4e4b\u4e00\u3002\u901a\u8fc7 DQL&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4ece\u6570\u636e\u5e93\u4e2d\u68c0\u7d22\u51fa\u6240\u9700\u7684\u6570\u636e&#xff0c;\u8fdb\u884c\u5404\u79cd\u590d\u6742\u7684\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8 MySQL DQL \u7684\u5404\u4e2a\u65b9\u9762&#xff0c;\u5e2e<\/p>\n","protected":false},"author":2,"featured_media":106764,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12124,114,768,100],"topic":[],"class_list":["post-106765","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-dql","tag-mysql","tag-sql","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MySQL DQL\u5168\u9762\u89e3\u6790\uff1a\u4ece\u5165\u95e8\u5230\u7cbe\u901a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/106765.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL DQL\u5168\u9762\u89e3\u6790\uff1a\u4ece\u5165\u95e8\u5230\u7cbe\u901a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u200b \u5728\u6570\u636e\u5e93\u7684\u5e7f\u9614\u5929\u5730\u4e2d&#xff0c;MySQL \u51ed\u501f\u5176\u5f00\u6e90\u3001\u9ad8\u6548\u3001\u6613\u7528\u7b49\u7279\u6027&#xff0c;\u6210\u4e3a\u4e86\u4f17\u591a\u5f00\u53d1\u8005\u7684\u9996\u9009\u3002\u800c\u5728 MySQL \u7684\u4f17\u591a\u529f\u80fd\u4e2d&#xff0c;\u6570\u636e\u67e5\u8be2\u8bed\u8a00&#xff08;Data Query Language&#xff0c;\u7b80\u79f0 DQL&#xff09;\u65e0\u7591\u662f\u6700\u4e3a\u5e38\u7528\u4e14\u5f3a\u5927\u7684\u90e8\u5206\u4e4b\u4e00\u3002\u901a\u8fc7 DQL&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4ece\u6570\u636e\u5e93\u4e2d\u68c0\u7d22\u51fa\u6240\u9700\u7684\u6570\u636e&#xff0c;\u8fdb\u884c\u5404\u79cd\u590d\u6742\u7684\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8 MySQL DQL \u7684\u5404\u4e2a\u65b9\u9762&#xff0c;\u5e2e\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/106765.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-18T01:48:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260918014857-6aac9889ceeac.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/106765.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/106765.html\",\"name\":\"MySQL DQL\u5168\u9762\u89e3\u6790\uff1a\u4ece\u5165\u95e8\u5230\u7cbe\u901a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-18T01:48:59+00:00\",\"dateModified\":\"2026-09-18T01:48:59+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/106765.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/106765.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/106765.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL DQL\u5168\u9762\u89e3\u6790\uff1a\u4ece\u5165\u95e8\u5230\u7cbe\u901a\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL DQL\u5168\u9762\u89e3\u6790\uff1a\u4ece\u5165\u95e8\u5230\u7cbe\u901a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/106765.html","og_locale":"zh_CN","og_type":"article","og_title":"MySQL DQL\u5168\u9762\u89e3\u6790\uff1a\u4ece\u5165\u95e8\u5230\u7cbe\u901a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u200b \u5728\u6570\u636e\u5e93\u7684\u5e7f\u9614\u5929\u5730\u4e2d&#xff0c;MySQL \u51ed\u501f\u5176\u5f00\u6e90\u3001\u9ad8\u6548\u3001\u6613\u7528\u7b49\u7279\u6027&#xff0c;\u6210\u4e3a\u4e86\u4f17\u591a\u5f00\u53d1\u8005\u7684\u9996\u9009\u3002\u800c\u5728 MySQL \u7684\u4f17\u591a\u529f\u80fd\u4e2d&#xff0c;\u6570\u636e\u67e5\u8be2\u8bed\u8a00&#xff08;Data Query Language&#xff0c;\u7b80\u79f0 DQL&#xff09;\u65e0\u7591\u662f\u6700\u4e3a\u5e38\u7528\u4e14\u5f3a\u5927\u7684\u90e8\u5206\u4e4b\u4e00\u3002\u901a\u8fc7 DQL&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4ece\u6570\u636e\u5e93\u4e2d\u68c0\u7d22\u51fa\u6240\u9700\u7684\u6570\u636e&#xff0c;\u8fdb\u884c\u5404\u79cd\u590d\u6742\u7684\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8 MySQL DQL \u7684\u5404\u4e2a\u65b9\u9762&#xff0c;\u5e2e","og_url":"https:\/\/www.wsisp.com\/helps\/106765.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-18T01:48:59+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260918014857-6aac9889ceeac.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/106765.html","url":"https:\/\/www.wsisp.com\/helps\/106765.html","name":"MySQL DQL\u5168\u9762\u89e3\u6790\uff1a\u4ece\u5165\u95e8\u5230\u7cbe\u901a - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-18T01:48:59+00:00","dateModified":"2026-09-18T01:48:59+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/106765.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/106765.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/106765.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"MySQL DQL\u5168\u9762\u89e3\u6790\uff1a\u4ece\u5165\u95e8\u5230\u7cbe\u901a"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/106765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=106765"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/106765\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/106764"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=106765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=106765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=106765"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=106765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}