sql-in

Sql İn

The SQL IN Operator

The IN administrator permits you to indicate numerous qualities in a WHERE statement.

The IN administrator is a shorthand for numerous OR conditions.

IN Syntax

SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1, value2, …);

or:

SELECT column_name(s)
FROM table_name
WHERE column_name IN (SELECT STATEMENT);

Demo Database

The table below shows the complete “Customers” table from the Northwind sample database:

CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
1Alfreds FutterkisteMaria AndersObere Str. 57Berlin12209Germany
2Ana Trujillo Emparedados y heladosAna TrujilloAvda. de la Constitución 2222México D.F.05021Mexico
3Antonio Moreno TaqueríaAntonio MorenoMataderos 2312México D.F.05023Mexico
4Around the HornThomas Hardy120 Hanover Sq.LondonWA1 1DPUK
5Berglunds snabbköpChristina BerglundBerguvsvägen 8LuleåS-958 22Sweden
6Blauer See DelikatessenHanna MoosForsterstr. 57Mannheim68306Germany
7Blondel père et filsFrédérique Citeaux24, place KléberStrasbourg67000France
8Bólido Comidas preparadasMartín SommerC/ Araquil, 67Madrid28023Spain
9Bon app’Laurence Lebihans12, rue des BouchersMarseille13008France
10Bottom-Dollar MarketseElizabeth Lincoln23 Tsawassen Blvd.TsawassenT2F 8M4Canada
11B’s BeveragesVictoria AshworthFauntleroy CircusLondonEC2 5NTUK
12Cactus Comidas para llevarPatricio SimpsonCerrito 333Buenos Aires1010Argentina
13Centro comercial MoctezumaFrancisco ChangSierras de Granada 9993México D.F.05022Mexico
14Chop-suey ChineseYang WangHauptstr. 29Bern3012Switzerland
15Comércio MineiroPedro AfonsoAv. dos Lusíadas, 23São Paulo05432-043Brazil
16Consolidated HoldingsElizabeth BrownBerkeley Gardens 12 BreweryLondonWX1 6LTUK
17Drachenblut DelikatessendSven OttliebWalserweg 21Aachen52066Germany
18Du monde entierJanine Labrune67, rue des Cinquante OtagesNantes44000France
19Eastern ConnectionAnn Devon35 King GeorgeLondonWX3 6FWUK
20Ernst HandelRoland MendelKirchgasse 6Graz8010Austria
21Familia ArquibaldoAria CruzRua Orós, 92São Paulo05442-030Brazil
22FISSA Fabrica Inter. Salchichas S.A.Diego RoelC/ Moralzarzal, 86Madrid28034Spain
23Folies gourmandesMartine Rancé184, chaussée de TournaiLille59000France
24Folk och fä HBMaria LarssonÅkergatan 24BräckeS-844 67Sweden
25FrankenversandPeter FrankenBerliner Platz 43München80805Germany
26France restaurationCarine Schmitt54, rue RoyaleNantes44000France
27Franchi S.p.A.Paolo AccortiVia Monte Bianco 34Torino10100Italy
28Furia Bacalhau e Frutos do MarLino RodriguezJardim das rosas n. 32Lisboa1675Portugal
29Galería del gastrónomoEduardo SaavedraRambla de Cataluña, 23Barcelona08022Spain
30Godos Cocina TípicaJosé Pedro FreyreC/ Romero, 33Sevilla41101Spain
31Gourmet LanchonetesAndré FonsecaAv. Brasil, 442Campinas04876-786Brazil
32Great Lakes Food MarketHoward Snyder2732 Baker Blvd.Eugene97403USA
33GROSELLA-RestauranteManuel Pereira5ª Ave. Los Palos GrandesCaracas1081Venezuela
34Hanari CarnesMario PontesRua do Paço, 67Rio de Janeiro05454-876Brazil
35HILARIÓN-AbastosCarlos HernándezCarrera 22 con Ave. Carlos Soublette #8-35San Cristóbal5022Venezuela
36Hungry Coyote Import StoreYoshi LatimerCity Center Plaza 516 Main St.Elgin97827USA
37Hungry Owl All-Night GrocersPatricia McKenna8 Johnstown RoadCorkIreland
38Island TradingHelen BennettGarden House Crowther WayCowesPO31 7PJUK
39Königlich EssenPhilip CramerMaubelstr. 90Brandenburg14776Germany
40La corne d’abondanceDaniel Tonini67, avenue de l’EuropeVersailles78000France
41La maison d’AsieAnnette Roulet1 rue Alsace-LorraineToulouse31000France
42Laughing Bacchus Wine CellarsYoshi Tannamuri1900 Oak St.VancouverV3F 2K1Canada
43Lazy K Kountry StoreJohn Steel12 Orchestra TerraceWalla Walla99362USA
44Lehmanns MarktstandRenate MessnerMagazinweg 7Frankfurt a.M.60528Germany
45Let’s Stop N ShopJaime Yorres87 Polk St. Suite 5San Francisco94117USA
46LILA-SupermercadoCarlos GonzálezCarrera 52 con Ave. Bolívar #65-98 Llano LargoBarquisimeto3508Venezuela
47LINO-DelicatesesFelipe IzquierdoAve. 5 de Mayo PorlamarI. de Margarita4980Venezuela
48Lonesome Pine RestaurantFran Wilson89 Chiaroscuro Rd.Portland97219USA
49Magazzini Alimentari RiunitiGiovanni RovelliVia Ludovico il Moro 22Bergamo24100Italy
50Maison DeweyCatherine DeweyRue Joseph-Bens 532BruxellesB-1180Belgium
51Mère PaillardeJean Fresnière43 rue St. LaurentMontréalH1J 1C3Canada
52Morgenstern GesundkostAlexander FeuerHeerstr. 22Leipzig04179Germany
53North/SouthSimon CrowtherSouth House 300 QueensbridgeLondonSW7 1RZUK
54Océano Atlántico Ltda.Yvonne MoncadaIng. Gustavo Moncada 8585 Piso 20-ABuenos Aires1010Argentina
55Old World DelicatessenRene Phillips2743 Bering St.Anchorage99508USA
56Ottilies KäseladenHenriette PfalzheimMehrheimerstr. 369Köln50739Germany
57Paris spécialitésMarie Bertrand265, boulevard CharonneParis75012France
58Pericles Comidas clásicasGuillermo FernándezCalle Dr. Jorge Cash 321México D.F.05033Mexico
59Piccolo und mehrGeorg PippsGeislweg 14Salzburg5020Austria
60Princesa Isabel VinhossIsabel de CastroEstrada da saúde n. 58Lisboa1756Portugal
61Que DelíciaBernardo BatistaRua da Panificadora, 12Rio de Janeiro02389-673Brazil
62Queen CozinhaLúcia CarvalhoAlameda dos Canàrios, 891São Paulo05487-020Brazil
63QUICK-StopHorst KlossTaucherstraße 10Cunewalde01307Germany
64Rancho grandeSergio GutiérrezAv. del Libertador 900Buenos Aires1010Argentina
65Rattlesnake Canyon GroceryPaula Wilson2817 Milton Dr.Albuquerque87110USA
66Reggiani CaseificiMaurizio MoroniStrada Provinciale 124Reggio Emilia42100Italy
67Ricardo AdocicadosJanete LimeiraAv. Copacabana, 267Rio de Janeiro02389-890Brazil
68Richter SupermarktMichael HolzGrenzacherweg 237Genève1203Switzerland
69Romero y tomilloAlejandra CaminoGran Vía, 1Madrid28001Spain
70Santé GourmetJonas BergulfsenErling Skakkes gate 78Stavern4110Norway
71Save-a-lot MarketsJose Pavarotti187 Suffolk Ln.Boise83720USA
72Seven Seas ImportsHari Kumar90 Wadhurst Rd.LondonOX15 4NBUK
73Simons bistroJytte PetersenVinbæltet 34København1734Denmark
74Spécialités du mondeDominique Perrier25, rue LauristonParis75016France
75Split Rail Beer & AleArt BraunschweigerP.O. Box 555Lander82520USA
76Suprêmes délicesPascale CartrainBoulevard Tirou, 255CharleroiB-6000Belgium
77The Big CheeseLiz Nixon89 Jefferson Way Suite 2Portland97201USA
78The Cracker BoxLiu Wong55 Grizzly Peak Rd.Butte59801USA
79Toms SpezialitätenKarin JosephsLuisenstr. 48Münster44087Germany
80Tortuga RestauranteMiguel Angel PaolinoAvda. Azteca 123México D.F.05033Mexico
81Tradição HipermercadosAnabela DominguesAv. Inês de Castro, 414São Paulo05634-030Brazil
82Trail’s Head Gourmet ProvisionersHelvetius Nagy722 DaVinci Blvd.Kirkland98034USA
83VaffeljernetPalle IbsenSmagsløget 45Århus8200Denmark
84Victuailles en stockMary Saveley2, rue du CommerceLyon69004France
85Vins et alcools ChevalierPaul Henriot59 rue de l’AbbayeReims51100France
86Die Wandernde KuhRita MüllerAdenauerallee 900Stuttgart70563Germany
87Wartian HerkkuPirkko KoskitaloTorikatu 38Oulu90110Finland
88Wellington ImportadoraPaula ParenteRua do Mercado, 12Resende08737-363Brazil
89White Clover MarketsKarl Jablonski305 – 14th Ave. S. Suite 3BSeattle98128USA
90Wilman KalaMatti KarttunenKeskuskatu 45Helsinki21240Finland
91WolskiZbyszekul. Filtrowa 68Walla01-012Poland

IN Operator Examples

The following SQL statement selects all customers that are located in “Germany”, “France” or “UK”:

Example

SELECT * FROM Customers
WHERE Country IN (‘Germany’‘France’‘UK’);

The following SQL statement selects all customers that are NOT located in “Germany”, “France” or “UK”:

Example

SELECT * FROM Customers
WHERE Country NOT IN (‘Germany’‘France’‘UK’);

The following SQL statement selects all customers that are from the same countries as the suppliers:

Example

SELECT * FROM Customers
WHERE Country IN (SELECT Country FROM Suppliers);