{"id":3902,"date":"2022-12-08T15:41:52","date_gmt":"2022-12-08T06:41:52","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/?p=3902"},"modified":"2022-12-08T15:41:52","modified_gmt":"2022-12-08T06:41:52","slug":"sql-join-in-exists","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2022\/12\/08\/sql-join-in-exists\/","title":{"rendered":"\u3010SQL\u3011JOIN, IN \u3068 EXISTS\u306e\u4f7f\u3044\u65b9"},"content":{"rendered":"
\u3053\u3093\u306b\u3061\u306f\u3001\u30df\u30f3\u3067\u3059\u3002 \u305d\u308c\u3067\u306f\u5b9f\u969b\u306b\u8a66\u3057\u3066\u307f\u305f\u3044\u306e\u30672\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u6e96\u5099\u3057\u307e\u3059\u3002 \u6e96\u5099\u3067\u304d\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3002<\/p>\n <\/p>\n WHERE\u53e5\u306e\u6761\u4ef6\u306b\u8907\u6570\u306e\u5024\u3092\u6307\u5b9a\u3057\u305f\u3044\u5834\u5408\u306b\u4e3b\u306b\u300cIN\u300d\u3092\u4f7f\u3044\u307e\u3059\u3002 \u69cb\u6587\uff1a<\/strong><\/p>\n \u4f8b\uff1a<\/strong> city='Tokyo'\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u62bd\u51fa\u3055\u308c\u307e\u3059\u3002 \u30cd\u30b9\u30c8\u3055\u308c\u305f\u30b5\u30d6\u30af\u30a8\u30ea\u306b\u6761\u4ef6\u306b\u30de\u30c3\u30c1\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u304c\u5b58\u5728\u3059\u308b\u304b\u5224\u5b9a\u3057\u305f\u3044\u6642\u306b\u4f7f\u3044\u307e\u3059\u3002 \u69cb\u6587\uff1a<\/strong><\/p>\n \u4f8b\uff1a<\/strong> \u3053\u3053\u3067customer_id = 3\u306eDavid\u3055\u3093\u306e\u30ec\u30b3\u30fc\u30c9\u306forders\u30c6\u30fc\u30d6\u30eb\u306b\u5b58\u5728\u3057\u306a\u3044\u305f\u3081\u62bd\u51fa\u3055\u308c\u3066\u306a\u3044\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002 2\u3064\u4ee5\u4e0a\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u95a2\u9023\u3065\u3044\u3066\u3044\u308b\u30ab\u30e9\u30e0\u3092\u8ef8\u306b\u7d50\u5408\u3057\u3001\u305d\u308c\u305e\u308c\u306e\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u30bf\u30d7\u30eb\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u3092\u9023\u7d50\u3057\u3066\u30c7\u30fc\u30bf\u62bd\u51fa\u3059\u308b\u6642\u306b\u4f7f\u3044\u307e\u3059\u3002 \u7d50\u5408\u3059\u308b\u4e21\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\u306bON\u3067\u6307\u5b9a\u3057\u305f\u6761\u4ef6\u306b\u30de\u30c3\u30c1\u3059\u308b\u5024\u307e\u305f\u306f\u30ec\u30b3\u30fc\u30c9\u306e\u307f\u8fd4\u3057\u307e\u3059\u3002 \u4f8b\uff1a<\/strong> <\/p>\n \u5de6\u5074\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u5168\u30ec\u30b3\u30fc\u30c9\u3068\u53f3\u5074\u306e\u30c6\u30fc\u30d6\u30eb\u304b\u3089ON\u3067\u6307\u5b9a\u3057\u305f\u6761\u4ef6\u306b\u30de\u30c3\u30c1\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u306e\u307f\u8fd4\u3057\u307e\u3059\u3002 \u4f8b\uff1a<\/strong> <\/p>\n \u5de6\u5074\u306e\u30c6\u30fc\u30d6\u30eb\u304b\u3089ON\u3067\u6307\u5b9a\u3057\u305f\u6761\u4ef6\u306b\u30de\u30c3\u30c1\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u306e\u307f\u3068\u53f3\u5074\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u5168\u30ec\u30b3\u30fc\u30c9\u8fd4\u3057\u307e\u3059\u3002 \u4f8b\uff1a<\/strong> <\/p>\n JOIN\u3059\u308b\u30c6\u30fc\u30d6\u30eb\u4e21\u65b9\u304b\u3089\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u306e\u307f\u8fd4\u3057\u307e\u3059\u3002 \u4f8b\uff1a<\/strong> MySQL\u3067\u306fFULL OUTER JOIN \u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002 <\/p>\n JOIN\u3059\u308b2\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u5404\u884c\u3092\u5168\u3066\u8fd4\u3057\u307e\u3059\u3002 \u4f8b\uff1a<\/strong> <\/p>\n \u540c\u4e00\u306e\u30c6\u30fc\u30d6\u30eb\u3092JOIN\u3057\u3066\u6761\u4ef6\u306b\u30de\u30c3\u30c1\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u306e\u307f\u8fd4\u3057\u307e\u3059\u3002 \u4f8b\uff1a<\/strong> <\/p>\n \u300cJOIN\u300d\u306f2\u3064\u4ee5\u4e0a\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u7d50\u5408\u3057\u30661\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u3068\u3057\u3066\u30c7\u30fc\u30bf\u3092\u62bd\u51fa\u3067\u304d\u307e\u3059\u3002 \u3053\u306e\u3088\u3046\u306bSQL\u306e JOIN, IN \u3068 EXISTS \u306e\u4f7f\u3044\u65b9\u3068\u4e3b\u306a\u9055\u3044\u3092\u8b58\u5225\u3057\u3066\u304a\u304f\u3068\u6709\u52b9\u306aSQL \u6587\u306e\u4f5c\u6210\u306b\u5f79\u306b\u7acb\u3064\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" \u306f\u3058\u3081\u306b \u3053\u3093\u306b\u3061\u306f\u3001\u30df\u30f3\u3067\u3059\u3002 \u4eca\u65e5\u306fSQL\u306e JOIN, IN \u3068 EXISTS \u6587\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u66f8\u3044\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002 \uff0a\u3053\u306e\u8a18\u4e8b\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f MySQL \u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002 \u305d\u308c\u3067\u306f\u5b9f\u969b\u306b\u8a66\u3057\u3066\u307f\u305f\u3044\u306e\u30672\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u6e96\u5099\u3057\u307e\u3059\u3002 \u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u306eSQL\u6587\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002 CREATE DATABASE test_db; USE test_db; CREATE TABLE cu […]<\/p>\n","protected":false},"author":27,"featured_media":4081,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[264],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/3902"}],"collection":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/comments?post=3902"}],"version-history":[{"count":17,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/3902\/revisions"}],"predecessor-version":[{"id":4184,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/3902\/revisions\/4184"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media\/4081"}],"wp:attachment":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media?parent=3902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/categories?post=3902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/tags?post=3902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
\n\u4eca\u65e5\u306fSQL\u306e JOIN, IN \u3068 EXISTS \u6587\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u66f8\u3044\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002
\n\uff0a\u3053\u306e\u8a18\u4e8b\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f MySQL \u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/em><\/p>\n
\n\u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u306eSQL\u6587\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\nCREATE DATABASE test_db;\nUSE test_db;\n\nCREATE TABLE customers ( customer_id int, customer_name varchar(255) NOT NULL, city varchar(255) );\nCREATE TABLE orders ( order_id int, customer_id int, order_date varchar(255) );\n\nINSERT INTO customers (customer_id, customer_name, City) VALUES \n(1, 'John', 'Tokyo'),\n(2, 'William', 'Osaka'),\n(3, 'David', 'Osaka') ;\n\nINSERT INTO orders (order_id, customer_id, order_date) VALUES \n(1, 1, '2022-11-01'),\n(2, 2, '2022-12-01') ;\n<\/code><\/pre>\n
SELECT * FROM customers;\nSELECT * FROM orders;<\/code><\/pre>\n
IN\u6f14\u7b97\u5b50<\/h2>\n
\n\u8907\u6570\u306e\u300cOR \u300d\u6761\u4ef6\u306e\u4ee3\u308f\u308a\u306b\u300cIN\u300d\u3092\u4f7f\u3048\u308b\u306e\u3067\u4fbf\u5229\u3067\u3059\u3002
\n\u300cIN\u300d\u6f14\u7b97\u5b50\u306e\u5426\u5b9a\u5f62\u306f\u300cNOT IN\u300d\u306b\u306a\u308a\u307e\u3059<\/p>\nSELECT col_name(s)\nFROM Table_name\nWHERE col_name IN(val1, val2, val3, \u2026..)<\/code><\/pre>\n
\ncity='Tokyo'<\/code>\u30ec\u30b3\u30fc\u30c9\u306e
customer_name<\/code>\u3092\u53d6\u5f97\u3002<\/p>\n
SELECT customer_name\nFROM customers\nWHERE city IN('Tokyo');<\/code><\/pre>\n
\n<\/p>\nEXISTS\u6f14\u7b97\u5b50<\/h2>\n
\n\u6761\u4ef6\u306b\u30de\u30c3\u30c1\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u304c1\u3064\u4ee5\u4e0a\u5b58\u5728\u3059\u308b\u5834\u5408\u306f Boolean TRUE\u3001\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f FALSE\u3092\u8fd4\u3057\u307e\u3059\u3002
\n\u300cIN\u300d\u6f14\u7b97\u5b50\u306e\u5426\u5b9a\u5f62\u3068\u540c\u3058\u3088\u3046\u306b\u3001\u300cEXISTS\u300d\u6f14\u7b97\u5b50\u306e\u5426\u5b9a\u5f62\u306f \u300cNOT EXISTS\u300d \u306b\u306a\u308a\u307e\u3059\u3002<\/p>\nSELECT\u00a0column_name(s)\nFROM\u00a0table_name\nWHERE\u00a0EXISTS\n(SELECT\u00a0column_name\u00a0FROM\u00a0table_name\u00a0WHERE\u00a0\u2019\u6761\u4ef6\u2019);<\/code><\/pre>\n
\norders<\/code>\u30c6\u30fc\u30d6\u30eb\u306b
customer_id<\/code>\u304c\u5b58\u5728\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u306b\u5bfe\u3057\u3066
customers<\/code>\u30c6\u30fc\u30d6\u30eb\u304b\u3089
customer_id, customer_name, city<\/code>\u3092\u53d6\u5f97\u3002<\/p>\n
SELECT customer_id, customer_name, city\nFROM customers\nWHERE EXISTS\n(SELECT * FROM orders WHERE orders.customer_id = customers.customer_id);<\/code><\/pre>\n
\n<\/p>\nJOIN\u53e5<\/h2>\n
\n\u4e21\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u30ec\u30b3\u30fc\u30c9\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f NULL \u5024\u3092\u8fd4\u3057\u307e\u3059\u3002
\nSQL \u306b\u306f\u3001\u57fa\u672c\u7684\u306b INNER JOIN, OUTER JOIN, CROSS JOIN \u3068 SELF JOIN \u306e4 \u7a2e\u985e\u306e JOINS \u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n1. INNER JOIN:<\/h3>\n
\n\u69cb\u6587\uff1a<\/strong><\/p>\nSELECT column_name(s)\nFROM table1\nINNER JOIN table2\nON table1.column_name = table2.column_name;<\/code><\/pre>\n
\ncustomers<\/code>\u30c6\u30fc\u30d6\u30eb\u3068
orders<\/code>\u30c6\u30fc\u30d6\u30eb\u304b\u3089
customer_id<\/code>\u304c\u4e00\u81f4\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3002<\/p>\n
SELECT *\nFROM customers\nINNER JOIN orders\nON customers.customer_id = orders.customer_id;<\/code><\/pre>\n
2. OUTER JOIN<\/h3>\n
LEFT JOIN \/ LEFT OUTER JOIN<\/h4>\n
\n\u69cb\u6587\uff1a<\/strong><\/p>\nSELECT column_name(s)\nFROM table1\nLEFT JOIN table2\nON table1.column_name = table2.column_name;<\/code><\/pre>\n
\n\u5de6\u5074customers<\/code>\u30c6\u30fc\u30d6\u30eb\u306e\u5168\u30ec\u30b3\u30fc\u30c9\u3068\u53f3\u5074
orders<\/code>\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u95a2\u9023\u3059\u308b\u30ab\u30e9\u30e0
customer_id<\/code>\u304c\u4e00\u81f4\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u306e\u307f\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u53d6\u5f97\u3002<\/p>\n
SELECT *\nFROM customers\nLEFT JOIN orders\nON customers.customer_id = orders.customer_id;<\/code><\/pre>\n
RIGHT JOIN \/ RIGHT OUTER JOIN<\/h4>\n
\n\u69cb\u6587\uff1a<\/strong><\/p>\nSELECT column_name(s)\nFROM table1\nRIGHT JOIN table2\nON table1.column_name = table2.column_name;<\/code><\/pre>\n
\n\u5de6\u5074customers<\/code>\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u95a2\u9023\u3059\u308b\u30ab\u30e9\u30e0
customer_id<\/code>\u304c\u4e00\u81f4\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u306e\u307f\u3068\u53f3\u5074
orders<\/code>\u30c6\u30fc\u30d6\u30eb\u306e\u5168\u30ec\u30b3\u30fc\u30c9\u3068\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u53d6\u5f97\u3002<\/p>\n
SELECT *\nFROM customers\nRIGHT JOIN orders\nON customers.customer_id = orders.customer_id;<\/code><\/pre>\n
FULL JOIN \/ FULL OUTER JOIN<\/h4>\n
\nWHERE\u6761\u4ef6\u3092\u4ed8\u3051\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u4f8b\u306e\u3088\u3046\u306b\u4e21\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u95a2\u9023\u3057\u3066\u3044\u308b\u30ec\u30b3\u30fc\u30c9\u306e\u7d44\u307f\u5408\u308f\u305b\u304c\u62bd\u51fa\u3055\u308c\u307e\u3059\u3002
\n\u69cb\u6587\uff1a<\/strong><\/p>\nSELECT column_name(s)\nFROM table1\nFULL OUTER JOIN table2\nON table1.column_name = table2.column_name\nWHERE \u2019\u6761\u4ef6\u2019;<\/code><\/pre>\n
\nWHERE\u6761\u4ef6\u306a\u3057\u3067customers<\/code>\u30c6\u30fc\u30d6\u30eb\u3068
orders<\/code>\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u5168\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3002<\/p>\n
SELECT customers.customer_name, orders.order_id\nFROM customers\nFULL OUTER JOIN orders ON Customers.CustomerID=orders.CustomerID\nORDER BY customers.customer_name;<\/code><\/pre>\n
\n\u3053\u306e\u5834\u5408\u306f JOIN, UNION \u3068LEFT JOIN\u3092\u5408\u308f\u305b\u3066\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u91cd\u8907\u3057\u3066\u3044\u308b\u30ec\u30b3\u30fc\u30c9\u3082\u53d6\u5f97\u3055\u308c\u3066\u3057\u307e\u3046\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002
\nWHERE\u6761\u4ef6\u3092\u4ed8\u3051\u3066\u3044\u306a\u3044\u305f\u3081\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u95a2\u9023\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u306e\u7d44\u307f\u5408\u308f\u305b\u304c\u62bd\u51fa\u3055\u308c\u307e\u3059\u3002
\n\u4f8b\uff08MySQL\u69cb\u6587\uff09\uff1a<\/strong><\/p>\nSELECT * FROM customers\nLEFT JOIN orders ON customers.customer_id = orders.customer_id\nUNION\nSELECT * FROM customers\nRIGHT JOIN orders ON customers.customer_id = orders.customer_id;<\/code><\/pre>\n
3. CROSS JOIN<\/h3>\n
\n\u95a2\u9023\u3057\u3066\u3044\u306a\u30442\u3064\u306e\u30c6\u30fc\u30d6\u30eb1\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u307e\u3068\u3081\u3066\u30c7\u30fc\u30bf\u62bd\u51fa\u3057\u305f\u3044\u6642\u306f\u4fbf\u5229\u3067\u3059\u3002
\n\u6ce8\u610f\uff1aCROSS JOIN\u306f\u5de6\u53f3\u306e\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u7247\u65b9\u3060\u3051\u306b\u30ec\u30b3\u30fc\u30c9\u304c\u5b58\u5728\u3059\u308b\u3053\u3068\u306b\u9650\u3089\u305a\u5168\u3066\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u8fd4\u3059\u306e\u3067\u30c7\u30fc\u30bf\u306e\u91cf\u304c\u591a\u3059\u304e\u3066\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u5f71\u97ff\u3057\u3066\u3057\u307e\u3046\u30b1\u30fc\u30b9\u304c\u3042\u308a\u307e\u3059\u3002
\n\u69cb\u6587\uff1a<\/strong><\/p>\nSELECT column_name(s)\nFROM table1\nCROSS JOIN table2;<\/code><\/pre>\n
\ncustomers<\/code>\u30c6\u30fc\u30d6\u30eb\u3068
orders<\/code>\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u30ec\u30b3\u30fc\u30c9\u5404\u884c\u3092\u5168\u3066\u53d6\u5f97\u3002<\/p>\n
SELECT customer_name, city, order_id, order_date \nFROM customers\nCROSS JOIN orders;<\/code><\/pre>\n
4. SELF JOIN<\/h3>\n
\n\u69cb\u6587\uff1a<\/strong><\/p>\nSELECT column_name(s)\nFROM table1 T1, table1 T2\nWHERE \u2019\u6761\u4ef6\u2019;<\/code><\/pre>\n
\ncustomers<\/code>\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u540c\u3058
city<\/code>\u3067
customer_name<\/code>\u304c\u9055\u3046\u30ec\u30b3\u30fc\u30c9\u306e\u307f\u53d6\u5f97\u3002<\/p>\n
SELECT T1.customer_name AS customer_name1, T2.customer_name AS customer_name2, T1.city\nFROM customers T1, customers T2\nWHERE T1.customer_name <> T2.customer_name\nAND T1.city = T2.city;<\/code><\/pre>\n
\u307e\u3068\u3081<\/h2>\n
\n\u300cIN\u300d\u306f\u8907\u6570\u306e\u300cOR\u300d\u6f14\u7b97\u5b50\u3068\u540c\u69d8\u306bWHERE\u53e5\u306e\u6761\u4ef6\u306b\u8907\u6570\u306e\u5024\u3092\u6307\u5b9a\u3057\u3066\u30de\u30c3\u30c1\u3059\u308b\u5168\u30ec\u30b3\u30fc\u30c9\u3092\u62bd\u51fa\u3067\u304d\u307e\u3059\u3002
\n\u300cEXISTS\u300d\u306f\u30b5\u30d6\u30af\u30a8\u30ea\u3067\u5225\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u6761\u4ef6\u306b\u30de\u30c3\u30c1\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u306e\u5b58\u5728\u6709\u7121\u306e\u30c1\u30a7\u30c3\u30af\u7d50\u679c\u3092\u57fa\u306b\u5fc5\u8981\u306a\u30c7\u30fc\u30bf\u3092\u62bd\u51fa\u3067\u304d\u307e\u3059\u3002<\/p>\n