{"id":181,"date":"2008-03-05T15:26:42","date_gmt":"2008-03-05T07:26:42","guid":{"rendered":"http:\/\/learn-house.idv.tw\/?p=181"},"modified":"2010-01-17T18:51:03","modified_gmt":"2010-01-17T10:51:03","slug":"sql%e5%b9%be%e5%80%8b%e5%a5%bd%e7%8e%a9%e7%9a%84sql%e8%aa%9e%e6%b3%95","status":"publish","type":"post","link":"https:\/\/learn-house.idv.tw\/?p=181","title":{"rendered":"[SQL]\u5e7e\u500b\u597d\u73a9\u7684SQL\u8a9e\u6cd5"},"content":{"rendered":"<p>\u4e00\u76f4\u4ee5\u4f86\u7a0b\u5f0f\u4e00\u76f4\u662f\u6211\u7684\u5f31\u9805\uff0c\u4e00\u76f4\u90fd\u5f88\u60f3\u5b78\u4f46\u537b\u53c8\u4e0d\u5f97\u5176\u9580\u800c\u5165<\/p>\n<p>\u6bcf\u6b21\u90fd\u4e09\u5206\u9418\u71b1\u5ea6\u7684\u73a9\u5473\u5e7e\u5929\uff0c\u5e7e\u5929\u5f8c\u5c31\u653e\u68c4\u800c\u4e1f\u5728\u4e00\u65c1&nbsp;<\/p>\n<p>\u525b\u597d\u6700\u8fd1\u8981\u5e6b\u5b78\u6821\u5beb\u4e00\u652f\u7d71\u8a08\u8cc7\u8a0a\u7684\u7a0b\u5f0f\uff0c\u4ee5\u53ca\u5176\u4ed6\u7684\u4e00\u4e9b\u529f\u80fd\uff0c\u624d\u6f38\u6f38\u7684\u5c0d\u7a0b\u5f0f\u6709\u8fd1\u4e00\u6b65\u7684\u4e86\u89e3<\/p>\n<p>\u4f46\u76ee\u524d\u7684\u6211\u7a0b\u5f0f\u5beb\u7684\u662f\u4e82\u7cdf\u7cdf\uff0c\u7d14\u7cb9\u662f\u70ba\u4e86\u60f3\u8981\u67d0\u4e9b\u529f\u80fd\u800c\u5beb\u67d0\u4e9b\u529f\u80fd\uff0c\u90fd\u6c92\u6709\u4ec0\u9ebc\u898f\u5283<\/p>\n<p>\u4e0d\u904e\u4e5f\u56e0\u70ba\u9019\u6b21\u7684\u6a5f\u6703\uff0c\u8b93\u6211\u5c0d\u7a0b\u5f0f\u4e5f\u8d8a\u4f86\u8d8a\u611f\u8208\u8da3\u4e0d\u518d\u5bb3\u6015&nbsp;<\/p>\n<p><strong>\u4e00\u3001&nbsp;<\/strong><\/p>\n<p><strong>\u8cc7\u6599\u8868(\u90e8\u4efd\u8cc7\u6599)<\/strong><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/mr.yuchin.googlepages.com\/mdl_resource.PNG\" border=\"0\" \/>&nbsp;<\/p>\n<p><strong>\u57f7\u884c&nbsp;<\/strong><\/p>\n<p>SELECT DISTINCT course , Count(course) AS C FROM mdl_resource GROUP BY course<\/p>\n<p><strong>\u7d50\u679c(\u90e8\u5206)&nbsp;<\/strong><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/mr.yuchin.googlepages.com\/mdl_resource1.PNG\" border=\"0\" \/>&nbsp;<\/p>\n<p><strong>\u8aaa\u660e<\/strong>&nbsp;<\/p>\n<p>\u900f\u904e\u4e0a\u9762\u8a9e\u6cd5\u5373\u80fd\u8a08\u7b97\u51fa\u4e0d\u540c\u7684course\u91cd\u8907\u7684\u6b21\u6578\uff1aDISTINCT course\u4ee3\u8868\u4e0d\u540c\u7684course\u6b04\u4f4d\uff0cCount(course) AS C \u8a08\u7b97\u76f8\u540ccourse\u503c\u7684\u6b21\u6578\u4e26\u628a\u8a08\u7b97\u7d50\u679c\u7684\u6b04\u4f4d\u6539\u6210C\u3002<\/p>\n<hr width=\"100%\" size=\"2\" \/>\n<p><strong>\u4e8c\u3001&nbsp;<\/strong><\/p>\n<p><strong>\u8cc7\u6599\u8868(\u90e8\u4efd\u8cc7\u6599)<\/strong><\/p>\n<p>mdl_user_teachers<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/mr.yuchin.googlepages.com\/mdl_user_teachers.PNG\" border=\"0\" \/>&nbsp;<\/p>\n<p><span>mdl_user<\/span><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/mr.yuchin.googlepages.com\/mdl_user.PNG\" border=\"0\" \/><\/p>\n<p><strong>\u57f7\u884c&nbsp;<\/strong><\/p>\n<p>select mdl_user_teachers.course from mdl_user_teachers,mdl_user where (((mdl_user.id)=31231) and ((mdl_user_teachers.userid)=31231))<\/p>\n<p><strong>\u7d50\u679c&nbsp;<\/strong><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/mr.yuchin.googlepages.com\/mdl_user_teachers1.PNG\" border=\"0\" \/>&nbsp;<\/p>\n<p><strong>\u8aaa\u660e&nbsp;<\/strong><\/p>\n<p>\u4e0b\u9019\u8a9e\u6cd5\u4e3b\u8981\u662f\u70ba\u4e86\u627e\u8a72\u4f7f\u7528\u8005\u7684course\uff0c\u800c\u4e14\u4ed6\u8981\u70ba\u8001\u5e2bmdl_user_teachers\u4e5f\u8981\u70ba\u4f7f\u7528\u8005<span>mdl_user<\/span><\/p>\n<p>&nbsp;<\/p>\n<hr width=\"100%\" size=\"2\" \/><strong>\u4e09\u3001<\/strong>&nbsp;<\/p>\n<p><strong>\u8cc7\u6599\u8868(\u90e8\u4efd\u8cc7\u6599)<\/strong><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/mr.yuchin.googlepages.com\/mdlcourse.PNG\" border=\"0\" \/>&nbsp;<\/p>\n<p><strong>\u57f7\u884c&nbsp;<\/strong><\/p>\n<p>SELECT * FROM mdl_course WHERE (fullname like &#8216;%\u5c08\u984c%&#8217;or fullname like &#8216;%\u8ad6\u6587%&#8217;) and (school_year = &#8217;96\u4e00&#8217;or school_year = &#8217;95\u4e8c&#8217; or school_year = &#8217;96\u4e8c&#8217;)<\/p>\n<p><strong>\u7d50\u679c<\/strong> <\/p>\n<p><img decoding=\"async\" src=\"http:\/\/mr.yuchin.googlepages.com\/mdlcourse2.PNG\" border=\"0\" \/>&nbsp;<\/p>\n<p><strong>\u8aaa\u660e&nbsp;<\/strong><\/p>\n<p><span>\u9019\u500b\u65b9\u6cd5\u53ef\u4ee5\u540c\u6642\u9078\u64c7\u6b04\u4f4dfullname\u5b57\u4e32\u88e1\u5305\u542b\u5c08\u984c\u6216\u8ad6\u6587\u7684\u6216\u8005\u662f<\/span>school_year\u662f95\u4e8c\u300196\u4e00\u300196\u4e8c\u7684\u8cc7\u6599<\/p>\n<hr width=\"100%\" size=\"2\" \/>\n<p><strong>\u56db\u3001<\/strong>&nbsp;<\/p>\n<p><strong>\u8cc7\u6599\u8868(\u90e8\u4efd\u8cc7\u6599)<\/strong><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/mr.yuchin.googlepages.com\/update1.PNG\" \/><\/p>\n<p><strong>\u57f7\u884c&nbsp;<\/strong><\/p>\n<p><span><span>UPDATE<\/span> <span>mdl_course<\/span>  <span>SET<\/span> <span>school_year<\/span>  <span>=<\/span> <span>96\u4e8c<\/span> <span>WHERE<\/span> <span>id<\/span>  <span>IN<\/span> <span>(<\/span><span>9870<\/span><span>,<\/span> <span>9871<\/span><span>,<\/span> <span>9872<\/span><span>,<\/span> <span>9873<\/span><span>,<\/span> <span>9874<\/span><span>,<\/span> <span>9875<\/span><span>,<\/span> <span>9876<\/span><span>,<\/span> <span>9877<\/span><span>)<\/span>&nbsp;<\/span><\/p>\n<p><strong>\u7d50\u679c<\/strong><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/mr.yuchin.googlepages.com\/update2.PNG\" \/><\/p>\n<p><strong>\u8aaa\u660e<\/strong><\/p>\n<p>\u4e0d\u7528\u8aaa\u61c9\u8a72\u77e5\u9053\u9019\u6bb5SQL\u7684\u529f\u7528\u5427!!&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: medium; color: #ff0000\"><strong>\u5099\u8a3b\uff1a<\/strong><\/span><span style=\"font-size: medium\"> \u96d6\u7136\u8aaaSQL\u8a9e\u6cd5\u6703\u7528\u5f88\u597d\u7528\uff0c\u53ef\u4ee5\u6e1b\u5c11\u5f88\u591aCoding\u7684\u5de5\u592b\uff0c\u4f46\u6211\u6709\u4e00\u6b21\u70ba\u4e86\u67e5\u8a62\u67d0\u8cc7\u6599\uff0c\u505a\u4e86\u592a\u8907\u96dc\u7684\u8cc7\u6599\u8868\u4ea4\u53c9\u6bd4\u5c0d\u904b\u7b97\uff0c\u7d50\u679c\u4f7f\u5f97\u6548\u80fd\u8b8a\u7684\u5f88\u4f4e\uff0c\u4e5f\u5c31\u662f\u8aaa\u958b\u555f\u7db2\u9801\u7684\u901f\u5ea6\u6703\u8b8a\u5f88\u6162\uff0c\u800c\u7528\u7a0b\u5f0fCoding\u4f86\u505a\u7be9\u9078\u5224\u65b7\uff0c\u4e0d\u5230\u4e00\u79d2\u9418\u7684\u6642\u9593\u7db2\u9801\u5c31\u986f\u793a\u51fa\u4f86!!<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u76f4\u4ee5\u4f86\u7a0b\u5f0f\u4e00\u76f4\u662f\u6211\u7684\u5f31\u9805\uff0c\u4e00\u76f4\u90fd\u5f88\u60f3\u5b78\u4f46\u537b\u53c8\u4e0d\u5f97\u5176\u9580\u800c\u5165 \u6bcf\u6b21\u90fd\u4e09\u5206\u9418\u71b1\u5ea6\u7684\u73a9\u5473\u5e7e\u5929\uff0c\u5e7e\u5929\u5f8c\u5c31\u653e\u68c4\u800c\u4e1f\u5728\u4e00\u65c1<span class=\"post-excerpt-end\">&hellip;<\/span><\/p>\n<p class=\"more-link\"><a href=\"https:\/\/learn-house.idv.tw\/?p=181\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-181","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=181"}],"version-history":[{"count":0,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/181\/revisions"}],"wp:attachment":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}