{"id":2073,"date":"2023-09-30T16:41:40","date_gmt":"2023-09-30T08:41:40","guid":{"rendered":"https:\/\/white-night.club\/?p=2073"},"modified":"2023-11-09T11:07:52","modified_gmt":"2023-11-09T03:07:52","slug":"ad20","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/09\/30\/ad20\/","title":{"rendered":"627.\u00a0\u53d8\u66f4\u6027\u522b"},"content":{"rendered":"\n<p><code>Salary<\/code>&nbsp;\u8868\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+----------+\n| Column Name | Type     |\n+-------------+----------+\n| id          | int      |\n| name        | varchar  |\n| sex         | ENUM     |\n| salary      | int      |\n+-------------+----------+\nid \u662f\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\uff08\u5177\u6709\u552f\u4e00\u503c\u7684\u5217\uff09\u3002\nsex \u8fd9\u4e00\u5217\u7684\u503c\u662f ENUM \u7c7b\u578b\uff0c\u53ea\u80fd\u4ece ('m', 'f') \u4e2d\u53d6\u3002\n\u672c\u8868\u5305\u542b\u516c\u53f8\u96c7\u5458\u7684\u4fe1\u606f\u3002\n<\/pre>\n\n\n\n<p>\u8bf7\u4f60\u7f16\u5199\u4e00\u4e2a\u89e3\u51b3\u65b9\u6848\u6765\u4ea4\u6362\u6240\u6709\u7684&nbsp;<code>'f'<\/code>&nbsp;\u548c&nbsp;<code>'m'<\/code>&nbsp;\uff08\u5373\uff0c\u5c06\u6240\u6709&nbsp;<code>'f'<\/code>&nbsp;\u53d8\u4e3a&nbsp;<code>'m'<\/code>&nbsp;\uff0c\u53cd\u4e4b\u4ea6\u7136\uff09\uff0c\u4ec5\u4f7f\u7528&nbsp;<strong>\u5355\u4e2a update \u8bed\u53e5<\/strong>&nbsp;\uff0c\u4e14\u4e0d\u4ea7\u751f\u4e2d\u95f4\u4e34\u65f6\u8868\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f\uff0c\u4f60\u5fc5\u987b\u4ec5\u4f7f\u7528\u4e00\u6761 update \u8bed\u53e5\uff0c\u4e14&nbsp;<strong>\u4e0d\u80fd<\/strong>&nbsp;\u4f7f\u7528 select \u8bed\u53e5\u3002<\/p>\n\n\n\n<p>\u7ed3\u679c\u5982\u4e0b\u4f8b\u6240\u793a\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>\nSalary \u8868\uff1a\n+----+------+-----+--------+\n| id | name | sex | salary |\n+----+------+-----+--------+\n| 1  | A    | m   | 2500   |\n| 2  | B    | f   | 1500   |\n| 3  | C    | m   | 5500   |\n| 4  | D    | f   | 500    |\n+----+------+-----+--------+\n<strong>\u8f93\u51fa\uff1a<\/strong>\n+----+------+-----+--------+\n| id | name | sex | salary |\n+----+------+-----+--------+\n| 1  | A    | f   | 2500   |\n| 2  | B    | m   | 1500   |\n| 3  | C    | f   | 5500   |\n| 4  | D    | m   | 500    |\n+----+------+-----+--------+\n<strong>\u89e3\u91ca\uff1a<\/strong>\n(1, A) \u548c (3, C) \u4ece 'm' \u53d8\u4e3a 'f' \u3002\n(2, B) \u548c (4, D) \u4ece 'f' \u53d8\u4e3a 'm' \u3002<\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>set&#8230;if(condition,conditon=true,condition=false)<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u505a\u70b9SQL\u9898\uff0c\u987a\u4fbf\u8bb0\u5f55\u4e0b\u6570\u636e\u5e93\u7684\u76f8\u5173\u77e5\u8bc6\u3002<\/p>\n\n\n\n<p>\u7537\u53d8\u5973\uff0c\u5973\u53d8\u7537\uff0c\u8fd8\u53ea\u80fd\u5199\u4e00\u6761update\u3002\u5982\u679c\u80fd\u5199\u4e24\u6761update\u90a3\u76f4\u63a5set\u5c31\u597d\u4e86\u3002<\/p>\n\n\n\n<p>\u4e0d\u8fc7\u5148\u6765\u8bf4\u8bf4if(A,B,C)\u7684\u7528\u6cd5\u5427\u3002\u8be5SQL\u8bed\u53e5\u8868\u793a\u7684\u662f\u201c\u5982\u679cA\u4e3a\u771f\uff0c\u8fd4\u56deB\uff1b\u5426\u5219\u8fd4\u56deC\u201d\u3002\u6709\u70b9\u50cfC\u8bed\u8a00\u91cc\u9762\u7684<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>return a:a?b;<\/code><\/pre>\n\n\n\n<p>\u77e5\u9053\u8fd9\u4e2a\u7528\u6cd5\u5c31\u5f88\u7b80\u5355\u4e86\uff0c\u76f4\u63a5SET\uff0c\u7136\u540e\u8c01\u771f\u5c31\u8fd4\u56de\u53e6\u4e00\u4e2a\uff0c\u5b8c\u4e8b\u3002\u561b\uff0c\u5982\u679c\u77e5\u9053if\u5728SET\u8fd9\u91cc\u80fd\u8fd9\u4e48\u7528\u7684\u8bdd\u8fd8\u662f\u633a\u7b80\u5355\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\nUPDATE Salary\nSET sex=if(sex='f','m','f');\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1aset&#8230;if&#8230;\u7684\u7528\u6cd5<\/p>\n","protected":false},"author":1,"featured_media":2827,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2073"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=2073"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2073\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2827"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=2073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2073"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}