{"id":3427,"date":"2016-07-27T03:53:37","date_gmt":"2016-07-27T03:53:37","guid":{"rendered":"https:\/\/kiencang.net\/?p=3427"},"modified":"2016-07-27T03:53:37","modified_gmt":"2016-07-27T03:53:37","slug":"toan-tu-trong-sql","status":"publish","type":"post","link":"https:\/\/kiencang.net\/toan-tu-trong-sql\/","title":{"rendered":"To\u00e1n t\u1eed IN trong SQL"},"content":{"rendered":"\n

To\u00e1n t\u1eed IN<\/code> cho ph\u00e9p b\u1ea1n ch\u1ec9 \u0111\u1ecbnh nhi\u1ec1u gi\u00e1 tr\u1ecb trong m\u1ec7nh \u0111\u1ec1 WHERE<\/code>.<\/p>\n\n\n\n

C\u00fa ph\u00e1p SQL IN<\/strong>:<\/p>\n\n\n\n

SELECT ten_cot (c\u00f3 th\u1ec3 nhi\u1ec1u c\u1ed9t)\nFROM ten_bang\nWHERE ten_cot IN (gia_tri_1,gia_tri_2,\u2026);<\/code><\/pre>\n\n\n\n
\n\n\n\n

C\u01a1 s\u1edf d\u1eef li\u1ec7u Demo<\/h2>\n\n\n\n

Trong b\u00e0i vi\u1ebft n\u00e0y ch\u00fang ta s\u1ebd s\u1eed d\u1ee5ng c\u01a1 s\u1edf d\u1eef li\u1ec7u m\u1eabu Northwind \u0111\u01b0\u1ee3c nhi\u1ec1u ng\u01b0\u1eddi bi\u1ebft \u0111\u1ebfn.<\/p>\n\n\n\n

D\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t l\u1ef1a ch\u1ecdn t\u1eeb b\u1ea3ng “Customers”:<\/p>\n\n\n\n

\n\n\n\n\n\n\n\n\n
CustomerID<\/th>\nCustomerName<\/th>\nContactName<\/th>\nAddress<\/th>\nCity<\/th>\nPostalCode<\/th>\nCountry<\/th>\n<\/tr>\n
1<\/td>\nAlfreds Futterkiste<\/td>\nMaria Anders<\/td>\nObere Str. 57<\/td>\nBerlin<\/td>\n12209<\/td>\nGermany<\/td>\n<\/tr>\n
2<\/td>\nAna Trujillo Emparedados y helados<\/td>\nAna Trujillo<\/td>\nAvda. de la Constituci\u00f3n 2222<\/td>\nM\u00e9xico D.F.<\/td>\n05021<\/td>\nMexico<\/td>\n<\/tr>\n
3<\/td>\nAntonio Moreno Taquer\u00eda<\/td>\nAntonio Moreno<\/td>\nMataderos 2312<\/td>\nM\u00e9xico D.F.<\/td>\n05023<\/td>\nMexico<\/td>\n<\/tr>\n
4<\/td>\nAround the Horn<\/td>\nThomas Hardy<\/td>\n120 Hanover Sq.<\/td>\nLondon<\/td>\nWA1 1DP<\/td>\nUK<\/td>\n<\/tr>\n
5<\/td>\nBerglunds snabbk\u00f6p<\/td>\nChristina Berglund<\/td>\nBerguvsv\u00e4gen 8<\/td>\nLule\u00e5<\/td>\nS-958 22<\/td>\nSweden<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n\n\n\n
\n\n\n\n

V\u00ed d\u1ee5 v\u1ec1 to\u00e1n t\u1eed IN<\/h2>\n\n\n\n

C\u00e2u l\u1ec7nh SQL sau l\u1ef1a ch\u1ecdn t\u1ea5t c\u1ea3 c\u00e1c kh\u00e1ch h\u00e0ng v\u1edbi City l\u00e0 “Paris” ho\u1eb7c “London”:<\/p>\n\n\n\n

SELECT * FROM Customers\nWHERE City IN ('Paris','London');<\/code><\/pre>\n\n\n\n

K\u1ebft qu\u1ea3 (l\u1ea5y ra hai v\u00ed d\u1ee5):<\/p>\n\n\n\n

\n\n\n\n\n
57<\/td>\nParis sp\u00e9cialit\u00e9s<\/td>\nMarie Bertrand<\/td>\n265, boulevard Charonne<\/td>\nParis<\/td>\n75012<\/td>\nFrance<\/td>\n<\/tr>\n
72<\/td>\nSeven Seas Imports<\/td>\nHari Kumar<\/td>\n90 Wadhurst Rd.<\/td>\nLondon<\/td>\nOX15 4NB<\/td>\nUK<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n","protected":false},"excerpt":{"rendered":"

To\u00e1n t\u1eed IN cho ph\u00e9p b\u1ea1n ch\u1ec9 \u0111\u1ecbnh nhi\u1ec1u gi\u00e1 tr\u1ecb trong m\u1ec7nh \u0111\u1ec1 WHERE. C\u00fa ph\u00e1p SQL IN: C\u01a1 s\u1edf d\u1eef li\u1ec7u Demo Trong b\u00e0i vi\u1ebft n\u00e0y ch\u00fang ta s\u1ebd s\u1eed d\u1ee5ng c\u01a1 s\u1edf d\u1eef li\u1ec7u m\u1eabu Northwind \u0111\u01b0\u1ee3c nhi\u1ec1u ng\u01b0\u1eddi bi\u1ebft \u0111\u1ebfn. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t l\u1ef1a ch\u1ecdn t\u1eeb b\u1ea3ng “Customers”: CustomerID CustomerName …<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[239],"tags":[],"yoast_head":"\nTo\u00e1n t\u1eed IN trong SQL • Ki\u1ebfn c\u00e0ng<\/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:\/\/kiencang.net\/toan-tu-trong-sql\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"To\u00e1n t\u1eed IN trong SQL • Ki\u1ebfn c\u00e0ng\" \/>\n<meta property=\"og:description\" content=\"To\u00e1n t\u1eed IN cho ph\u00e9p b\u1ea1n ch\u1ec9 \u0111\u1ecbnh nhi\u1ec1u gi\u00e1 tr\u1ecb trong m\u1ec7nh \u0111\u1ec1 WHERE. C\u00fa ph\u00e1p SQL IN: C\u01a1 s\u1edf d\u1eef li\u1ec7u Demo Trong b\u00e0i vi\u1ebft n\u00e0y ch\u00fang ta s\u1ebd s\u1eed d\u1ee5ng c\u01a1 s\u1edf d\u1eef li\u1ec7u m\u1eabu Northwind \u0111\u01b0\u1ee3c nhi\u1ec1u ng\u01b0\u1eddi bi\u1ebft \u0111\u1ebfn. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t l\u1ef1a ch\u1ecdn t\u1eeb b\u1ea3ng “Customers”: CustomerID CustomerName …\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kiencang.net\/toan-tu-trong-sql\/\" \/>\n<meta property=\"og:site_name\" content=\"Ki\u1ebfn c\u00e0ng\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/anhducnguyen87\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-27T03:53:37+00:00\" \/>\n<meta name=\"author\" content=\"Nguy\u1ec5n \u0110\u1ee9c Anh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nguy\u1ec5n \u0110\u1ee9c Anh\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 ph\u00fat\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"To\u00e1n t\u1eed IN trong SQL • Ki\u1ebfn c\u00e0ng","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:\/\/kiencang.net\/toan-tu-trong-sql\/","og_locale":"vi_VN","og_type":"article","og_title":"To\u00e1n t\u1eed IN trong SQL • Ki\u1ebfn c\u00e0ng","og_description":"To\u00e1n t\u1eed IN cho ph\u00e9p b\u1ea1n ch\u1ec9 \u0111\u1ecbnh nhi\u1ec1u gi\u00e1 tr\u1ecb trong m\u1ec7nh \u0111\u1ec1 WHERE. C\u00fa ph\u00e1p SQL IN: C\u01a1 s\u1edf d\u1eef li\u1ec7u Demo Trong b\u00e0i vi\u1ebft n\u00e0y ch\u00fang ta s\u1ebd s\u1eed d\u1ee5ng c\u01a1 s\u1edf d\u1eef li\u1ec7u m\u1eabu Northwind \u0111\u01b0\u1ee3c nhi\u1ec1u ng\u01b0\u1eddi bi\u1ebft \u0111\u1ebfn. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t l\u1ef1a ch\u1ecdn t\u1eeb b\u1ea3ng “Customers”: CustomerID CustomerName …","og_url":"https:\/\/kiencang.net\/toan-tu-trong-sql\/","og_site_name":"Ki\u1ebfn c\u00e0ng","article_author":"https:\/\/www.facebook.com\/anhducnguyen87\/","article_published_time":"2016-07-27T03:53:37+00:00","author":"Nguy\u1ec5n \u0110\u1ee9c Anh","twitter_card":"summary_large_image","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"Nguy\u1ec5n \u0110\u1ee9c Anh","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"1 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/kiencang.net\/toan-tu-trong-sql\/","url":"https:\/\/kiencang.net\/toan-tu-trong-sql\/","name":"To\u00e1n t\u1eed IN trong SQL • Ki\u1ebfn c\u00e0ng","isPartOf":{"@id":"https:\/\/kiencang.net\/#website"},"datePublished":"2016-07-27T03:53:37+00:00","dateModified":"2016-07-27T03:53:37+00:00","author":{"@id":"https:\/\/kiencang.net\/#\/schema\/person\/5e7e1a04d8d1218ad8c421ba43d25c16"},"breadcrumb":{"@id":"https:\/\/kiencang.net\/toan-tu-trong-sql\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kiencang.net\/toan-tu-trong-sql\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kiencang.net\/toan-tu-trong-sql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kiencang.net\/"},{"@type":"ListItem","position":2,"name":"To\u00e1n t\u1eed IN trong SQL"}]},{"@type":"WebSite","@id":"https:\/\/kiencang.net\/#website","url":"https:\/\/kiencang.net\/","name":"Ki\u1ebfn c\u00e0ng","description":"\u00d4m l\u00fd thuy\u1ebft, h\u00f4n th\u1ef1c h\u00e0nh","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kiencang.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"vi"},{"@type":"Person","@id":"https:\/\/kiencang.net\/#\/schema\/person\/5e7e1a04d8d1218ad8c421ba43d25c16","name":"Nguy\u1ec5n \u0110\u1ee9c Anh","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/kiencang.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6d71f9b89393952a8382e30dad26c1ec?s=96&d=monsterid&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6d71f9b89393952a8382e30dad26c1ec?s=96&d=monsterid&r=g","caption":"Nguy\u1ec5n \u0110\u1ee9c Anh"},"description":"Sinh n\u0103m 1987, t\u1ed1t nghi\u1ec7p Cao \u0111\u1eb3ng th\u1ef1c h\u00e0nh FPT qu\u00e3ng 2014, chuy\u00ean ng\u00e0nh Thi\u1ebft k\u1ebf website. T\u00f4i th\u00edch Content, SEO, Ads, T\u0103ng t\u1ed1c website v\u00e0 Th\u01b0\u01a1ng m\u1ea1i \u0111i\u1ec7n t\u1eed. B\u00ean c\u1ea1nh b\u00e0i t\u1ef1 vi\u1ebft, t\u00f4i c\u0169ng d\u1ecbch nhi\u1ec1u n\u1ed9i dung th\u00fa v\u1ecb c\u1ee7a c\u00e1c t\u00e1c gi\u1ea3 kh\u00e1c nhau. FB c\u00e1 nh\u00e2n: facebook.com\/anhducnguyen87. Email li\u00ean h\u1ec7: guiemailchotoi@gmail.com","sameAs":["https:\/\/www.facebook.com\/anhducnguyen87\/"],"url":"https:\/\/kiencang.net\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/posts\/3427"}],"collection":[{"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/comments?post=3427"}],"version-history":[{"count":0,"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/posts\/3427\/revisions"}],"wp:attachment":[{"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/media?parent=3427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/categories?post=3427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/tags?post=3427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}