{"id":2098,"date":"2023-10-02T16:30:14","date_gmt":"2023-10-02T08:30:14","guid":{"rendered":"https:\/\/white-night.club\/?p=2098"},"modified":"2023-11-09T11:07:51","modified_gmt":"2023-11-09T03:07:51","slug":"ad22","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/02\/ad22\/","title":{"rendered":"183.\u00a0\u4ece\u4e0d\u8ba2\u8d2d\u7684\u5ba2\u6237"},"content":{"rendered":"\n<p><code>Customers<\/code>\u00a0\u8868\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+---------+\n| Column Name | Type    |\n+-------------+---------+\n| id          | int     |\n| name        | varchar |\n+-------------+---------+\n\u5728 SQL \u4e2d\uff0cid \u662f\u8be5\u8868\u7684\u4e3b\u952e\u3002\n\u8be5\u8868\u7684\u6bcf\u4e00\u884c\u90fd\u8868\u793a\u5ba2\u6237\u7684 ID \u548c\u540d\u79f0\u3002<\/pre>\n\n\n\n<p><code>Orders<\/code>&nbsp;\u8868\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| id          | int  |\n| customerId  | int  |\n+-------------+------+\n\u5728 SQL \u4e2d\uff0cid \u662f\u8be5\u8868\u7684\u4e3b\u952e\u3002\ncustomerId \u662f Customers \u8868\u4e2d ID \u7684\u5916\u952e( Pandas \u4e2d\u7684\u8fde\u63a5\u952e)\u3002\n\u8be5\u8868\u7684\u6bcf\u4e00\u884c\u90fd\u8868\u793a\u8ba2\u5355\u7684 ID \u548c\u8ba2\u8d2d\u8be5\u8ba2\u5355\u7684\u5ba2\u6237\u7684 ID\u3002<\/pre>\n\n\n\n<p>\u627e\u51fa\u6240\u6709\u4ece\u4e0d\u70b9\u4efb\u4f55\u4e1c\u897f\u7684\u987e\u5ba2\u3002<\/p>\n\n\n\n<p>\u4ee5&nbsp;<strong>\u4efb\u610f\u987a\u5e8f<\/strong>&nbsp;\u8fd4\u56de\u7ed3\u679c\u8868\u3002<\/p>\n\n\n\n<p>\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\u6240\u793a\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>\nCustomers table:\n+----+-------+\n| id | name  |\n+----+-------+\n| 1  | Joe   |\n| 2  | Henry |\n| 3  | Sam   |\n| 4  | Max   |\n+----+-------+\nOrders table:\n+----+------------+\n| id | customerId |\n+----+------------+\n| 1  | 3          |\n| 2  | 1          |\n+----+------------+\n<strong>\u8f93\u51fa\uff1a<\/strong>\n+-----------+\n| Customers |\n+-----------+\n| Henry     |\n| Max       |\n+-----------+<\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\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>\u591a\u8868\u67e5\u8be2<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u7ed9\u4e86\u4e24\u4e2a\u8868\uff0c\u4e00\u4e2aCustomers\u8868\uff0c\u4e00\u4e2aOrders\u8868\u3002\u90a3\u80af\u5b9a\u662f\u8981\u591a\u8868\u67e5\u8be2\u4e86\u3002\u518d\u770b\u4e0b\u9898\u76ee\uff0c\u8981\u627e\u7684\u662f<strong>\u4e0d\u4e70\u4e1c\u897f\u7684\u4eba<\/strong>\uff0c\u800cOrders\u8868\u91cc\u9762\u7684customersId\u8981\u5728Customers\u8868\u4e2d\u51fa\u73b0\u8fc7\uff0c\u90a3\u7528\u4e2aNOT EXISTS\u5c31\u597d\u4e86\u3002\u5982\u679c\u8981\u627e\u4e70\u8fc7\u4e1c\u897f\u7684\u4eba\u90a3\u5c31\u7528EXISTS\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT A.name AS Customers\r\nFROM Customers AS A\r\nWHERE NOT EXISTS(\r\n  SELECT B.customerId FROM Orders AS B\r\n  WHERE A.id=B.customerId\r\n)\r<\/code><\/pre>\n\n\n\n<p>\u4e0d\u8fc7\u770b\u4e86\u4e0b\u9898\u89e3\uff0c\u8fd8\u53ef\u4ee5\u7528\u66f4\u7b80\u4fbf\u7684\u683c\u5f0f\u53bb\u5199\u3002\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\r\nSELECT name AS Customers from Customers \r\nWHERE NOT EXISTS(\r\n  SELECT customerId from Orders WHERE customerId=Customers.id\r\n)\r<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u591a\u8868\u67e5\u8be2<\/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\/2098"}],"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=2098"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2098\/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=2098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}