Perintah SQL Menampilkan Data Tertentu

Perintah SQL Menampilkan Data Tertentu

Salah satu tujuan utama perintah SQL adalah memberikan informasi berupa data dari tabel pada database. Informasi yang diberikan dapat berasal dari satu tabel. Informasi yang diberikan juga dapat difilter berdasarkan kriteria tertentu. Perintah SQL yang lebih rumit bahkan bisa memberikan informasi dari beberapa tabel sekaligus. Pada tutorial ini kita akan mempelajari berbagai cara menampilkan data dari satu tabel. Perintah SQL jenis ini juga biasa disebut dengan istilah Query. Query adalah perintah SQL yang bertujuan untuk menampilkan data tertentu dari tabel.

Data Awal Untuk Contoh Query

Semua contoh query SQL pada artikel ini dijalankan kepada tabel Customers dan Products. Data tabel Customers dan Products terlampir di bawah ini.

Tabel Customers

CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 
Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico 
Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico 
Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK 
Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden 
Blauer See Delikatessen Hanna Moos Forsterstr. 57 Mannheim 68306 Germany 
Blondel père et fils Frédérique Citeaux 24, place Kléber Strasbourg 67000 France 
Bólido Comidas preparadas Martín Sommer C/ Araquil, 67 Madrid 28023 Spain 
Bon app’ Laurence Lebihans 12, rue des Bouchers Marseille 13008 France 
10 Bottom-Dollar Marketse Elizabeth Lincoln 23 Tsawassen Blvd. Tsawassen T2F 8M4 Canada 
11 B’s Beverages Victoria Ashworth Fauntleroy Circus London EC2 5NT UK 
12 Cactus Comidas para llevar Patricio Simpson Cerrito 333 Buenos Aires 1010 Argentina 
13 Centro comercial Moctezuma Francisco Chang Sierras de Granada 9993 México D.F. 05022 Mexico 
14 Chop-suey Chinese Yang Wang Hauptstr. 29 Bern 3012 Switzerland 
15 Comércio Mineiro Pedro Afonso Av. dos Lusíadas, 23 São Paulo 05432-043 Brazil 
16 Consolidated Holdings Elizabeth Brown Berkeley Gardens 12 Brewery  London WX1 6LT UK 
17 Drachenblut Delikatessend Sven Ottlieb Walserweg 21 Aachen 52066 Germany 
18 Du monde entier Janine Labrune 67, rue des Cinquante Otages Nantes 44000 France 
19 Eastern Connection Ann Devon 35 King George London WX3 6FW UK 
20 Ernst Handel Roland Mendel Kirchgasse 6 Graz 8010 Austria 
21 Familia Arquibaldo Aria Cruz Rua Orós, 92 São Paulo 05442-030 Brazil 
22 FISSA Fabrica Inter. Salchichas S.A. Diego Roel C/ Moralzarzal, 86 Madrid 28034 Spain 
23 Folies gourmandes Martine Rancé 184, chaussée de Tournai Lille 59000 France 
24 Folk och fä HB Maria Larsson Åkergatan 24 Bräcke S-844 67 Sweden 
25 Frankenversand Peter Franken Berliner Platz 43 München 80805 Germany 
26 France restauration Carine Schmitt 54, rue Royale Nantes 44000 France 
27 Franchi S.p.A. Paolo Accorti Via Monte Bianco 34 Torino 10100 Italy 
28 Furia Bacalhau e Frutos do Mar Lino Rodriguez  Jardim das rosas n. 32 Lisboa 1675 Portugal 
29 Galería del gastrónomo Eduardo Saavedra Rambla de Cataluña, 23 Barcelona 08022 Spain 
30 Godos Cocina Típica José Pedro Freyre C/ Romero, 33 Sevilla 41101 Spain 
31 Gourmet Lanchonetes André Fonseca Av. Brasil, 442 Campinas 04876-786 Brazil 
32 Great Lakes Food Market Howard Snyder 2732 Baker Blvd. Eugene 97403 USA 
33 GROSELLA-Restaurante Manuel Pereira 5ª Ave. Los Palos Grandes Caracas 1081 Venezuela 
34 Hanari Carnes Mario Pontes Rua do Paço, 67 Rio de Janeiro 05454-876 Brazil 
35 HILARIÓN-Abastos Carlos Hernández Carrera 22 con Ave. Carlos Soublette #8-35 San Cristóbal 5022 Venezuela 
36 Hungry Coyote Import Store Yoshi Latimer City Center Plaza 516 Main St. Elgin 97827 USA 
37 Hungry Owl All-Night Grocers Patricia McKenna 8 Johnstown Road Cork  Ireland 
38 Island Trading Helen Bennett Garden House Crowther Way Cowes PO31 7PJ UK 
39 Königlich Essen Philip Cramer Maubelstr. 90 Brandenburg 14776 Germany 
40 La corne d’abondance Daniel Tonini 67, avenue de l’Europe Versailles 78000 France 
41 La maison d’Asie Annette Roulet 1 rue Alsace-Lorraine Toulouse 31000 France 
42 Laughing Bacchus Wine Cellars Yoshi Tannamuri 1900 Oak St. Vancouver V3F 2K1 Canada 
43 Lazy K Kountry Store John Steel 12 Orchestra Terrace Walla Walla 99362 USA 
44 Lehmanns Marktstand Renate Messner Magazinweg 7 Frankfurt a.M.  60528 Germany 
45 Let’s Stop N Shop Jaime Yorres 87 Polk St. Suite 5 San Francisco 94117 USA 
46 LILA-Supermercado Carlos González Carrera 52 con Ave. Bolívar #65-98 Llano Largo Barquisimeto 3508 Venezuela 
47 LINO-Delicateses Felipe Izquierdo Ave. 5 de Mayo Porlamar I. de Margarita 4980 Venezuela 
48 Lonesome Pine Restaurant Fran Wilson 89 Chiaroscuro Rd. Portland 97219 USA 
49 Magazzini Alimentari Riuniti Giovanni Rovelli Via Ludovico il Moro 22 Bergamo 24100 Italy 
50 Maison Dewey Catherine Dewey Rue Joseph-Bens 532 Bruxelles B-1180 Belgium 
51 Mère Paillarde Jean Fresnière 43 rue St. Laurent Montréal H1J 1C3 Canada 
52 Morgenstern Gesundkost Alexander Feuer Heerstr. 22 Leipzig 04179 Germany 
53 North/South Simon Crowther South House 300 Queensbridge London SW7 1RZ UK 
54 Océano Atlántico Ltda. Yvonne Moncada Ing. Gustavo Moncada 8585 Piso 20-A Buenos Aires 1010 Argentina 
55 Old World Delicatessen Rene Phillips 2743 Bering St. Anchorage 99508 USA 
56 Ottilies Käseladen Henriette Pfalzheim Mehrheimerstr. 369 Köln 50739 Germany 
57 Paris spécialités Marie Bertrand 265, boulevard Charonne Paris 75012 France 
58 Pericles Comidas clásicas Guillermo Fernández Calle Dr. Jorge Cash 321 México D.F. 05033 Mexico 
59 Piccolo und mehr Georg Pipps Geislweg 14 Salzburg 5020 Austria 
60 Princesa Isabel Vinhoss Isabel de Castro Estrada da saúde n. 58 Lisboa 1756 Portugal 
61 Que Delícia Bernardo Batista Rua da Panificadora, 12 Rio de Janeiro 02389-673 Brazil 
62 Queen Cozinha Lúcia Carvalho Alameda dos Canàrios, 891 São Paulo 05487-020 Brazil 
63 QUICK-Stop Horst Kloss Taucherstraße 10 Cunewalde 01307 Germany 
64 Rancho grande Sergio Gutiérrez Av. del Libertador 900 Buenos Aires 1010 Argentina 
65 Rattlesnake Canyon Grocery Paula Wilson 2817 Milton Dr. Albuquerque 87110 USA 
66 Reggiani Caseifici Maurizio Moroni Strada Provinciale 124 Reggio Emilia 42100 Italy 
67 Ricardo Adocicados Janete Limeira Av. Copacabana, 267 Rio de Janeiro 02389-890 Brazil 
68 Richter Supermarkt Michael Holz Grenzacherweg 237 Genève 1203 Switzerland 
69 Romero y tomillo Alejandra Camino Gran Vía, 1 Madrid 28001 Spain 
70 Santé Gourmet Jonas Bergulfsen Erling Skakkes gate 78 Stavern 4110 Norway 
71 Save-a-lot Markets Jose Pavarotti 187 Suffolk Ln. Boise 83720 USA 
72 Seven Seas Imports Hari Kumar 90 Wadhurst Rd. London OX15 4NB UK 
73 Simons bistro Jytte Petersen Vinbæltet 34 København 1734 Denmark 
74 Spécialités du monde Dominique Perrier 25, rue Lauriston Paris 75016 France 
75 Split Rail Beer & Ale Art Braunschweiger P.O. Box 555 Lander 82520 USA 
76 Suprêmes délices Pascale Cartrain Boulevard Tirou, 255 Charleroi B-6000 Belgium 
77 The Big Cheese Liz Nixon 89 Jefferson Way Suite 2 Portland 97201 USA 
78 The Cracker Box Liu Wong 55 Grizzly Peak Rd. Butte 59801 USA 
79 Toms Spezialitäten Karin Josephs Luisenstr. 48 Münster 44087 Germany 
80 Tortuga Restaurante Miguel Angel Paolino Avda. Azteca 123 México D.F. 05033 Mexico 
81 Tradição Hipermercados Anabela Domingues Av. Inês de Castro, 414 São Paulo 05634-030 Brazil 
82 Trail’s Head Gourmet Provisioners Helvetius Nagy 722 DaVinci Blvd. Kirkland 98034 USA 
83 Vaffeljernet Palle Ibsen Smagsløget 45 Århus 8200 Denmark 
84 Victuailles en stock Mary Saveley 2, rue du Commerce Lyon 69004 France 
85 Vins et alcools Chevalier Paul Henriot 59 rue de l’Abbaye Reims 51100 France 
86 Die Wandernde Kuh Rita Müller Adenauerallee 900 Stuttgart 70563 Germany 
87 Wartian Herkku Pirkko Koskitalo Torikatu 38 Oulu 90110 Finland 
88 Wellington Importadora Paula Parente Rua do Mercado, 12 Resende 08737-363 Brazil 
89 White Clover Markets Karl Jablonski 305 – 14th Ave. S. Suite 3B Seattle 98128 USA 
90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 
91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland 

Tabel Products

ProductIDProductNameSupplierIDCategoryIDUnitPrice
Chais 10 boxes x 20 bags 18 
Chang 24 – 12 oz bottles 19 
Aniseed Syrup 12 – 550 ml bottles 10 
Chef Anton’s Cajun Seasoning 48 – 6 oz jars 22 
Chef Anton’s Gumbo Mix 36 boxes 21.35 
Grandma’s Boysenberry Spread 12 – 8 oz jars 25 
Uncle Bob’s Organic Dried Pears 12 – 1 lb pkgs. 30 
Northwoods Cranberry Sauce 12 – 12 oz jars 40 
Mishi Kobe Niku 18 – 500 g pkgs. 97 
10 Ikura 12 – 200 ml jars 31 
11 Queso Cabrales 1 kg pkg. 21 
12 Queso Manchego La Pastora 10 – 500 g pkgs. 38 
13 Konbu 2 kg box 
14 Tofu 40 – 100 g pkgs. 23.25 
15 Genen Shouyu 24 – 250 ml bottles 15.5 
16 Pavlova 32 – 500 g boxes 17.45 
17 Alice Mutton 20 – 1 kg tins 39 
18 Carnarvon Tigers 16 kg pkg. 62.5 
19 Teatime Chocolate Biscuits 10 boxes x 12 pieces 9.2 
20 Sir Rodney’s Marmalade 30 gift boxes 81 
21 Sir Rodney’s Scones 24 pkgs. x 4 pieces 10 
22 Gustaf’s Knäckebröd 24 – 500 g pkgs. 21 
23 Tunnbröd 12 – 250 g pkgs. 
24 Guaraná Fantástica 10 12 – 355 ml cans 4.5 
25 NuNuCa Nuß-Nougat-Creme 11 20 – 450 g glasses 14 
26 Gumbär Gummibärchen 11 100 – 250 g bags 31.23 
27 Schoggi Schokolade 11 100 – 100 g pieces 43.9 
28 Rössle Sauerkraut 12 25 – 825 g cans 45.6 
29 Thüringer Rostbratwurst 12 50 bags x 30 sausgs. 123.79 
30 Nord-Ost Matjeshering 13 10 – 200 g glasses 25.89 
31 Gorgonzola Telino 14 12 – 100 g pkgs 12.5 
32 Mascarpone Fabioli 14 24 – 200 g pkgs. 32 
33 Geitost 15 500 g 2.5 
34 Sasquatch Ale 16 24 – 12 oz bottles 14 
35 Steeleye Stout 16 24 – 12 oz bottles 18 
36 Inlagd Sill 17 24 – 250 g jars 19 
37 Gravad lax 17 12 – 500 g pkgs. 26 
38 Côte de Blaye 18 12 – 75 cl bottles 263.5 
39 Chartreuse verte 18 750 cc per bottle 18 
40 Boston Crab Meat 19 24 – 4 oz tins 18.4 
41 Jack’s New England Clam Chowder 19 12 – 12 oz cans 9.65 
42 Singaporean Hokkien Fried Mee 20 32 – 1 kg pkgs. 14 
43 Ipoh Coffee 20 16 – 500 g tins 46 
44 Gula Malacca 20 20 – 2 kg bags 19.45 
45 Røgede sild 21 1k pkg. 9.5 
46 Spegesild 21 4 – 450 g glasses 12 
47 Zaanse koeken 22 10 – 4 oz boxes 9.5 
48 Chocolade 22 10 pkgs. 12.75 
49 Maxilaku 23 24 – 50 g pkgs. 20 
50 Valkoinen suklaa 23 12 – 100 g bars 16.25 
51 Manjimup Dried Apples 24 50 – 300 g pkgs. 53 
52 Filo Mix 24 16 – 2 kg boxes 
53 Perth Pasties 24 48 pieces 32.8 
54 Tourtière 25 16 pies 7.45 
55 Pâté chinois 25 24 boxes x 2 pies 24 
56 Gnocchi di nonna Alice 26 24 – 250 g pkgs. 38 
57 Ravioli Angelo 26 24 – 250 g pkgs. 19.5 
58 Escargots de Bourgogne 27 24 pieces 13.25 
59 Raclette Courdavault 28 5 kg pkg. 55 
60 Camembert Pierrot 28 15 – 300 g rounds 34 
61 Sirop d’érable 29 24 – 500 ml bottles 28.5 
62 Tarte au sucre 29 48 pies 49.3 
63 Vegie-spread 15 – 625 g jars 43.9 
64 Wimmers gute Semmelknödel 12 20 bags x 4 pieces 33.25 
65 Louisiana Fiery Hot Pepper Sauce 32 – 8 oz bottles 21.05 
66 Louisiana Hot Spiced Okra 24 – 8 oz jars 17 
67 Laughing Lumberjack Lager 16 24 – 12 oz bottles 14 
68 Scottish Longbreads 10 boxes x 8 pieces 12.5 
69 Gudbrandsdalsost 15 10 kg pkg. 36 
70 Outback Lager 24 – 355 ml bottles 15 
71 Fløtemysost 15 10 – 500 g pkgs. 21.5 
72 Mozzarella di Giovanni 14 24 – 200 g pkgs. 34.8 
73 Röd Kaviar 17 24 – 150 g jars 15 
74 Longlife Tofu 5 kg pkg. 10 
75 Rhönbräu Klosterbier 12 24 – 0.5 l bottles 7.75 
76 Lakkalikööri 23 500 ml  18 
77 Original Frankfurter grüne Soße 12 12 boxes 13 

 

Semua artikel dalam seri tutorial belajar SQL ini menggunakan sampel database yang dapat didownload di sini. Silahkan import sampel database ke MySql untuk keperluan praktek perintah SQL.

Perintah SELECT

Perintah atau query SELECT digunakan untuk menampilkan data dari tabel pada database. Di bawah ini adalah format sederhana dari perintah SELECT.

SELECT column1, column2, ...
FROM table_name;

Column1 dan column2 adalah kolom-kolom pada tabel yang ingin ditampilkan. Table_name adalah nama tabel sumber data. Gunakan tanda * (wildcard) untuk menampilkan semua kolom dari suatu tabel.

SELECT * FROM table_name;

 

Contoh SELECT Kolom Tertentu

SELECT CustomerName, City FROM Customers;
CustomerNameCity
Alfreds FutterkisteBerlin
Ana Trujillo Emparedados y heladosMéxico D.F.
Antonio Moreno TaqueríaMéxico D.F.
Around the HornLondon
Berglunds snabbköpLuleå
Blauer See DelikatessenMannheim
Blondel père et filsStrasbourg
Bólido Comidas preparadasMadrid
Bon app’Marseille
Bottom-Dollar MarketseTsawassen
B’s BeveragesLondon
Cactus Comidas para llevarBuenos Aires
Centro comercial MoctezumaMéxico D.F.
Chop-suey ChineseBern
Comércio MineiroSão Paulo
Consolidated HoldingsLondon
Drachenblut DelikatessendAachen
Du monde entierNantes
Eastern ConnectionLondon
Ernst HandelGraz
Familia ArquibaldoSão Paulo
FISSA Fabrica Inter. Salchichas S.A.Madrid
Folies gourmandesLille
Folk och fä HBBräcke
FrankenversandMünchen
France restaurationNantes
Franchi S.p.A.Torino
Furia Bacalhau e Frutos do MarLisboa
Galería del gastrónomoBarcelona
Godos Cocina TípicaSevilla
Gourmet LanchonetesCampinas
Great Lakes Food MarketEugene
GROSELLA-RestauranteCaracas
Hanari CarnesRio de Janeiro
HILARIÓN-AbastosSan Cristóbal
Hungry Coyote Import StoreElgin
Hungry Owl All-Night GrocersCork
Island TradingCowes
Königlich EssenBrandenburg
La corne d’abondanceVersailles
La maison d’AsieToulouse
Laughing Bacchus Wine CellarsVancouver
Lazy K Kountry StoreWalla Walla
Lehmanns MarktstandFrankfurt a.M.
Let’s Stop N ShopSan Francisco
LILA-SupermercadoBarquisimeto
LINO-DelicatesesI. de Margarita
Lonesome Pine RestaurantPortland
Magazzini Alimentari RiunitiBergamo
Maison DeweyBruxelles
Mère PaillardeMontréal
Morgenstern GesundkostLeipzig
North/SouthLondon
Océano Atlántico Ltda.Buenos Aires
Old World DelicatessenAnchorage
Ottilies KäseladenKöln
Paris spécialitésParis
Pericles Comidas clásicasMéxico D.F.
Piccolo und mehrSalzburg
Princesa Isabel VinhossLisboa
Que DelíciaRio de Janeiro
Queen CozinhaSão Paulo
QUICK-StopCunewalde
Rancho grandeBuenos Aires
Rattlesnake Canyon GroceryAlbuquerque
Reggiani CaseificiReggio Emilia
Ricardo AdocicadosRio de Janeiro
Richter SupermarktGenève
Romero y tomilloMadrid
Santé GourmetStavern
Save-a-lot MarketsBoise
Seven Seas ImportsLondon
Simons bistroKøbenhavn
Spécialités du mondeParis
Split Rail Beer & AleLander
Suprêmes délicesCharleroi
The Big CheesePortland
The Cracker BoxButte
Toms SpezialitätenMünster
Tortuga RestauranteMéxico D.F.
Tradição HipermercadosSão Paulo
Trail’s Head Gourmet ProvisionersKirkland
VaffeljernetÅrhus
Victuailles en stockLyon
Vins et alcools ChevalierReims
Die Wandernde KuhStuttgart
Wartian HerkkuOulu
Wellington ImportadoraResende
White Clover MarketsSeattle
Wilman KalaHelsinki
WolskiWalla

 

Contoh SELECT Semua Kolom

SELECT * FROM Customers;
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

SELECT DISTINCT

Perintah SELECT DISTINCT merupakan query SELECT yang berfungsi untuk menampilkan data tanpa adanya duplikasi atau baris data yang sama. Baris data yang sama akan dihapus dari hasil query. Format SELECT DISTINCT hampir sama dengan SELECT biasa, bedanya hanya ditambahkan kata DISTINCT di depan kata SELECT.

SELECT DISTINCT column1, column2, ...
FROM table_name;

Contoh SELECT Tanpa DISTINCT

SELECT Country FROM Customers;
Country
Germany
Mexico
Mexico
UK
Sweden
Germany
France
Spain
France
Canada
UK
Argentina
Mexico
Switzerland
Brazil
UK
Germany
France
UK
Austria
Brazil
Spain
France
Sweden
Germany
France
Italy
Portugal
Spain
Spain
Brazil
USA
Venezuela
Brazil
Venezuela
USA
Ireland
UK
Germany
France
France
Canada
USA
Germany
USA
Venezuela
Venezuela
USA
Italy
Belgium
Canada
Germany
UK
Argentina
USA
Germany
France
Mexico
Austria
Portugal
Brazil
Brazil
Germany
Argentina
USA
Italy
Brazil
Switzerland
Spain
Norway
USA
UK
Denmark
France
USA
Belgium
USA
USA
Germany
Mexico
Brazil
USA
Denmark
France
France
Germany
Finland
Brazil
USA
Finland
Poland

 

Contoh SELECT Dengan DISTINCT

SELECT DISTINCT Country FROM Customers;
Country
Germany
Mexico
UK
Sweden
France
Spain
Canada
Argentina
Switzerland
Brazil
Austria
Italy
Portugal
USA
Venezuela
Ireland
Belgium
Norway
Denmark
Finland
Poland

SELECT WHERE

Perintah SELECT WHERE merupakan query SELECT yang berfungsi untuk menampilkan data dengan menambahkan filter berdasarkan kondisi tertentu. Data yang ditampilkan adalah data yang lolos dari proses filter berdasarkan kondisi tertentu.

Berikut adalah format SELECT WHERE dengan kondisi.

SELECT column1, column2, ...
FROM table_name
WHERE condition;

Contoh SELECT WHERE

Contoh di bawah ini memperlihatkan query SELECT dengan kondisi nilai kolom Country sama dengan ‘Mexico’. Data yang ditampilkan hanya baris-baris data dengan kolom Country bernilai ‘Mexico’. Gunakan single quote untuk menuliskan nilai dengan tipe text pada perintah SQL.

SELECT * FROM Customers
WHERE Country='Mexico';
CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
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
13Centro comercial MoctezumaFrancisco ChangSierras de Granada 9993México D.F.05022Mexico
58Pericles Comidas clásicasGuillermo FernándezCalle Dr. Jorge Cash 321México D.F.05033Mexico
80Tortuga RestauranteMiguel Angel PaolinoAvda. Azteca 123México D.F.05033Mexico

 

Contoh Kondisi Kolom Tipe Angka

Single quote tidak dipakai pada nilai dengan tipe angka.

SELECT * FROM Customers
WHERE CustomerID=1;
CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
1Alfreds FutterkisteMaria AndersObere Str. 57Berlin12209Germany

Jenis Kondisi

Terdapat berbagai jenis kondisi yang bisa dipakai pada SELECT WHERE.

Contoh Kondisi Sama Dengan

Gunakan operator = untuk menuliskan kondisi sama dengan. Contoh di bawah ini hanya menampilkan data dengan kondisi nilai kolom Price sama dengan 18.

SELECT * FROM Products
WHERE Price = 18;
ProductIDProductNameSupplierIDCategoryIDUnitPrice
1Chais1110 boxes x 20 bags18
35Steeleye Stout16124 – 12 oz bottles18
39Chartreuse verte181750 cc per bottle18
76Lakkalikööri231500 ml18

 

Contoh Kondisi Lebih Besar

Gunakan operator > untuk menuliskan kondisi lebih besar. Contoh di bawah ini hanya menampilkan data dengan kondisi nilai kolom Price lebih besar dari 30.

SELECT * FROM Products
WHERE Price > 30;
ProductIDProductNameSupplierIDCategoryIDUnitPrice
8Northwoods Cranberry Sauce3212 – 12 oz jars40
9Mishi Kobe Niku4618 – 500 g pkgs.97
10Ikura4812 – 200 ml jars31
12Queso Manchego La Pastora5410 – 500 g pkgs.38
17Alice Mutton7620 – 1 kg tins39
18Carnarvon Tigers7816 kg pkg.62.5
20Sir Rodney’s Marmalade8330 gift boxes81
26Gumbär Gummibärchen113100 – 250 g bags31.23
27Schoggi Schokolade113100 – 100 g pieces43.9
28Rössle Sauerkraut12725 – 825 g cans45.6
29Thüringer Rostbratwurst12650 bags x 30 sausgs.123.79
32Mascarpone Fabioli14424 – 200 g pkgs.32
38Côte de Blaye18112 – 75 cl bottles263.5
43Ipoh Coffee20116 – 500 g tins46
51Manjimup Dried Apples24750 – 300 g pkgs.53
53Perth Pasties24648 pieces32.8
56Gnocchi di nonna Alice26524 – 250 g pkgs.38
59Raclette Courdavault2845 kg pkg.55
60Camembert Pierrot28415 – 300 g rounds34
62Tarte au sucre29348 pies49.3
63Vegie-spread7215 – 625 g jars43.9
64Wimmers gute Semmelknödel12520 bags x 4 pieces33.25
69Gudbrandsdalsost15410 kg pkg.36
72Mozzarella di Giovanni14424 – 200 g pkgs.34.8

 

Contoh Kondisi Lebih Kecil

Gunakan operator < untuk menuliskan kondisi lebih kecil. Contoh di bawah ini hanya menampilkan data dengan kondisi nilai kolom Price lebih kecil dari 30.

SELECT * FROM Products
WHERE Price < 30;
ProductIDProductNameSupplierIDCategoryIDUnitPrice
1Chais1110 boxes x 20 bags18
2Chang1124 – 12 oz bottles19
3Aniseed Syrup1212 – 550 ml bottles10
4Chef Anton’s Cajun Seasoning2248 – 6 oz jars22
5Chef Anton’s Gumbo Mix2236 boxes21.35
6Grandma’s Boysenberry Spread3212 – 8 oz jars25
11Queso Cabrales541 kg pkg.21
13Konbu682 kg box6
14Tofu6740 – 100 g pkgs.23.25
15Genen Shouyu6224 – 250 ml bottles15.5
16Pavlova7332 – 500 g boxes17.45
19Teatime Chocolate Biscuits8310 boxes x 12 pieces9.2
21Sir Rodney’s Scones8324 pkgs. x 4 pieces10
22Gustaf’s Knäckebröd9524 – 500 g pkgs.21
23Tunnbröd9512 – 250 g pkgs.9
24Guaraná Fantástica10112 – 355 ml cans4.5
25NuNuCa Nuß-Nougat-Creme11320 – 450 g glasses14
30Nord-Ost Matjeshering13810 – 200 g glasses25.89
31Gorgonzola Telino14412 – 100 g pkgs12.5
33Geitost154500 g2.5
34Sasquatch Ale16124 – 12 oz bottles14
35Steeleye Stout16124 – 12 oz bottles18
36Inlagd Sill17824 – 250 g jars19
37Gravad lax17812 – 500 g pkgs.26
39Chartreuse verte181750 cc per bottle18
40Boston Crab Meat19824 – 4 oz tins18.4
41Jack’s New England Clam Chowder19812 – 12 oz cans9.65
42Singaporean Hokkien Fried Mee20532 – 1 kg pkgs.14
44Gula Malacca20220 – 2 kg bags19.45
45Røgede sild2181k pkg.9.5
46Spegesild2184 – 450 g glasses12
47Zaanse koeken22310 – 4 oz boxes9.5
48Chocolade22310 pkgs.12.75
49Maxilaku23324 – 50 g pkgs.20
50Valkoinen suklaa23312 – 100 g bars16.25
52Filo Mix24516 – 2 kg boxes7
54Tourtière25616 pies7.45
55Pâté chinois25624 boxes x 2 pies24
57Ravioli Angelo26524 – 250 g pkgs.19.5
58Escargots de Bourgogne27824 pieces13.25
61Sirop d’érable29224 – 500 ml bottles28.5
65Louisiana Fiery Hot Pepper Sauce2232 – 8 oz bottles21.05
66Louisiana Hot Spiced Okra2224 – 8 oz jars17
67Laughing Lumberjack Lager16124 – 12 oz bottles14
68Scottish Longbreads8310 boxes x 8 pieces12.5
70Outback Lager7124 – 355 ml bottles15
71Fløtemysost15410 – 500 g pkgs.21.5
73Röd Kaviar17824 – 150 g jars15
74Longlife Tofu475 kg pkg.10
75Rhönbräu Klosterbier12124 – 0.5 l bottles7.75
76Lakkalikööri231500 ml18
77Original Frankfurter grüne Soße12212 boxes13

 

Contoh Kondisi Lebih Besar Sama Dengan

Gunakan operator >= untuk menuliskan kondisi lebih besar atau sama dengan. Contoh di bawah ini hanya menampilkan data dengan kondisi nilai kolom Price lebih besar atau sama dengan 30.

SELECT * FROM Products
WHERE Price >= 30;
ProductIDProductNameSupplierIDCategoryIDUnitPrice
7Uncle Bob’s Organic Dried Pears3712 – 1 lb pkgs.30
8Northwoods Cranberry Sauce3212 – 12 oz jars40
9Mishi Kobe Niku4618 – 500 g pkgs.97
10Ikura4812 – 200 ml jars31
12Queso Manchego La Pastora5410 – 500 g pkgs.38
17Alice Mutton7620 – 1 kg tins39
18Carnarvon Tigers7816 kg pkg.62.5
20Sir Rodney’s Marmalade8330 gift boxes81
26Gumbär Gummibärchen113100 – 250 g bags31.23
27Schoggi Schokolade113100 – 100 g pieces43.9
28Rössle Sauerkraut12725 – 825 g cans45.6
29Thüringer Rostbratwurst12650 bags x 30 sausgs.123.79
32Mascarpone Fabioli14424 – 200 g pkgs.32
38Côte de Blaye18112 – 75 cl bottles263.5
43Ipoh Coffee20116 – 500 g tins46
51Manjimup Dried Apples24750 – 300 g pkgs.53
53Perth Pasties24648 pieces32.8
56Gnocchi di nonna Alice26524 – 250 g pkgs.38
59Raclette Courdavault2845 kg pkg.55
60Camembert Pierrot28415 – 300 g rounds34
62Tarte au sucre29348 pies49.3
63Vegie-spread7215 – 625 g jars43.9
64Wimmers gute Semmelknödel12520 bags x 4 pieces33.25
69Gudbrandsdalsost15410 kg pkg.36
72Mozzarella di Giovanni14424 – 200 g pkgs.34.8

 

Contoh Kondisi Lebih Kecil Sama Dengan

Gunakan operator <= untuk menuliskan kondisi lebih kecil atau sama dengan. Contoh di bawah ini hanya menampilkan data dengan kondisi nilai kolom Price lebih kecil atau sama dengan 30.

SELECT * FROM Products
WHERE Price <= 30;
ProductIDProductNameSupplierIDCategoryIDUnitPrice
1Chais1110 boxes x 20 bags18
2Chang1124 – 12 oz bottles19
3Aniseed Syrup1212 – 550 ml bottles10
4Chef Anton’s Cajun Seasoning2248 – 6 oz jars22
5Chef Anton’s Gumbo Mix2236 boxes21.35
6Grandma’s Boysenberry Spread3212 – 8 oz jars25
7Uncle Bob’s Organic Dried Pears3712 – 1 lb pkgs.30
11Queso Cabrales541 kg pkg.21
13Konbu682 kg box6
14Tofu6740 – 100 g pkgs.23.25
15Genen Shouyu6224 – 250 ml bottles15.5
16Pavlova7332 – 500 g boxes17.45
19Teatime Chocolate Biscuits8310 boxes x 12 pieces9.2
21Sir Rodney’s Scones8324 pkgs. x 4 pieces10
22Gustaf’s Knäckebröd9524 – 500 g pkgs.21
23Tunnbröd9512 – 250 g pkgs.9
24Guaraná Fantástica10112 – 355 ml cans4.5
25NuNuCa Nuß-Nougat-Creme11320 – 450 g glasses14
30Nord-Ost Matjeshering13810 – 200 g glasses25.89
31Gorgonzola Telino14412 – 100 g pkgs12.5
33Geitost154500 g2.5
34Sasquatch Ale16124 – 12 oz bottles14
35Steeleye Stout16124 – 12 oz bottles18
36Inlagd Sill17824 – 250 g jars19
37Gravad lax17812 – 500 g pkgs.26
39Chartreuse verte181750 cc per bottle18
40Boston Crab Meat19824 – 4 oz tins18.4
41Jack’s New England Clam Chowder19812 – 12 oz cans9.65
42Singaporean Hokkien Fried Mee20532 – 1 kg pkgs.14
44Gula Malacca20220 – 2 kg bags19.45
45Røgede sild2181k pkg.9.5
46Spegesild2184 – 450 g glasses12
47Zaanse koeken22310 – 4 oz boxes9.5
48Chocolade22310 pkgs.12.75
49Maxilaku23324 – 50 g pkgs.20
50Valkoinen suklaa23312 – 100 g bars16.25
52Filo Mix24516 – 2 kg boxes7
54Tourtière25616 pies7.45
55Pâté chinois25624 boxes x 2 pies24
57Ravioli Angelo26524 – 250 g pkgs.19.5
58Escargots de Bourgogne27824 pieces13.25
61Sirop d’érable29224 – 500 ml bottles28.5
65Louisiana Fiery Hot Pepper Sauce2232 – 8 oz bottles21.05
66Louisiana Hot Spiced Okra2224 – 8 oz jars17
67Laughing Lumberjack Lager16124 – 12 oz bottles14
68Scottish Longbreads8310 boxes x 8 pieces12.5
70Outback Lager7124 – 355 ml bottles15
71Fløtemysost15410 – 500 g pkgs.21.5
73Röd Kaviar17824 – 150 g jars15
74Longlife Tofu475 kg pkg.10
75Rhönbräu Klosterbier12124 – 0.5 l bottles7.75
76Lakkalikööri231500 ml18
77Original Frankfurter grüne Soße12212 boxes13

 

Contoh Kondisi Tidak Sama Dengan

Gunakan operator <> untuk menuliskan kondisi tidak sama dengan. Contoh di bawah ini hanya menampilkan data dengan kondisi nilai kolom Price tidak sama dengan 18.

SELECT * FROM Products
WHERE Price <> 18;
ProductIDProductNameSupplierIDCategoryIDUnitPrice
2Chang1124 – 12 oz bottles19
3Aniseed Syrup1212 – 550 ml bottles10
4Chef Anton’s Cajun Seasoning2248 – 6 oz jars22
5Chef Anton’s Gumbo Mix2236 boxes21.35
6Grandma’s Boysenberry Spread3212 – 8 oz jars25
7Uncle Bob’s Organic Dried Pears3712 – 1 lb pkgs.30
8Northwoods Cranberry Sauce3212 – 12 oz jars40
9Mishi Kobe Niku4618 – 500 g pkgs.97
10Ikura4812 – 200 ml jars31
11Queso Cabrales541 kg pkg.21
12Queso Manchego La Pastora5410 – 500 g pkgs.38
13Konbu682 kg box6
14Tofu6740 – 100 g pkgs.23.25
15Genen Shouyu6224 – 250 ml bottles15.5
16Pavlova7332 – 500 g boxes17.45
17Alice Mutton7620 – 1 kg tins39
18Carnarvon Tigers7816 kg pkg.62.5
19Teatime Chocolate Biscuits8310 boxes x 12 pieces9.2
20Sir Rodney’s Marmalade8330 gift boxes81
21Sir Rodney’s Scones8324 pkgs. x 4 pieces10
22Gustaf’s Knäckebröd9524 – 500 g pkgs.21
23Tunnbröd9512 – 250 g pkgs.9
24Guaraná Fantástica10112 – 355 ml cans4.5
25NuNuCa Nuß-Nougat-Creme11320 – 450 g glasses14
26Gumbär Gummibärchen113100 – 250 g bags31.23
27Schoggi Schokolade113100 – 100 g pieces43.9
28Rössle Sauerkraut12725 – 825 g cans45.6
29Thüringer Rostbratwurst12650 bags x 30 sausgs.123.79
30Nord-Ost Matjeshering13810 – 200 g glasses25.89
31Gorgonzola Telino14412 – 100 g pkgs12.5
32Mascarpone Fabioli14424 – 200 g pkgs.32
33Geitost154500 g2.5
34Sasquatch Ale16124 – 12 oz bottles14
36Inlagd Sill17824 – 250 g jars19
37Gravad lax17812 – 500 g pkgs.26
38Côte de Blaye18112 – 75 cl bottles263.5
40Boston Crab Meat19824 – 4 oz tins18.4
41Jack’s New England Clam Chowder19812 – 12 oz cans9.65
42Singaporean Hokkien Fried Mee20532 – 1 kg pkgs.14
43Ipoh Coffee20116 – 500 g tins46
44Gula Malacca20220 – 2 kg bags19.45
45Røgede sild2181k pkg.9.5
46Spegesild2184 – 450 g glasses12
47Zaanse koeken22310 – 4 oz boxes9.5
48Chocolade22310 pkgs.12.75
49Maxilaku23324 – 50 g pkgs.20
50Valkoinen suklaa23312 – 100 g bars16.25
51Manjimup Dried Apples24750 – 300 g pkgs.53
52Filo Mix24516 – 2 kg boxes7
53Perth Pasties24648 pieces32.8
54Tourtière25616 pies7.45
55Pâté chinois25624 boxes x 2 pies24
56Gnocchi di nonna Alice26524 – 250 g pkgs.38
57Ravioli Angelo26524 – 250 g pkgs.19.5
58Escargots de Bourgogne27824 pieces13.25
59Raclette Courdavault2845 kg pkg.55
60Camembert Pierrot28415 – 300 g rounds34
61Sirop d’érable29224 – 500 ml bottles28.5
62Tarte au sucre29348 pies49.3
63Vegie-spread7215 – 625 g jars43.9
64Wimmers gute Semmelknödel12520 bags x 4 pieces33.25
65Louisiana Fiery Hot Pepper Sauce2232 – 8 oz bottles21.05
66Louisiana Hot Spiced Okra2224 – 8 oz jars17
67Laughing Lumberjack Lager16124 – 12 oz bottles14
68Scottish Longbreads8310 boxes x 8 pieces12.5
69Gudbrandsdalsost15410 kg pkg.36
70Outback Lager7124 – 355 ml bottles15
71Fløtemysost15410 – 500 g pkgs.21.5
72Mozzarella di Giovanni14424 – 200 g pkgs.34.8
73Röd Kaviar17824 – 150 g jars15
74Longlife Tofu475 kg pkg.10
75Rhönbräu Klosterbier12124 – 0.5 l bottles7.75
77Original Frankfurter grüne Soße12212 boxes13

 

Kondisi Menampilkan Data Dalam Range Tertentu

Gunakan BETWEEN AND untuk menuliskan kondisi untuk menampilkan data dalam range tertentu. Contoh di bawah ini hanya menampilkan data dengan kondisi nilai kolom Price bernilai di antara 50 sampai 60.

SELECT * FROM Products
WHERE Price BETWEEN 50 AND 60;
ProductIDProductNameSupplierIDCategoryIDUnitPrice
51Manjimup Dried Apples24750 – 300 g pkgs.53
59Raclette Courdavault2845 kg pkg.55

 

Contoh Kondisi LIKE

Contoh di bawah ini hanya menampilkan data dengan kondisi nilai kolom City berawalan huruf s.

SELECT * FROM Customers
WHERE City LIKE 's%';
CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
7Blondel père et filsFrédérique Citeaux24, place KléberStrasbourg67000France
15Comércio MineiroPedro AfonsoAv. dos Lusíadas, 23São Paulo05432-043Brazil
21Familia ArquibaldoAria CruzRua Orós, 92São Paulo05442-030Brazil
30Godos Cocina TípicaJosé Pedro FreyreC/ Romero, 33Sevilla41101Spain
35HILARIÓN-AbastosCarlos HernándezCarrera 22 con Ave. Carlos Soublette #8-35San Cristóbal5022Venezuela
45Let’s Stop N ShopJaime Yorres87 Polk St. Suite 5San Francisco94117USA
59Piccolo und mehrGeorg PippsGeislweg 14Salzburg5020Austria
62Queen CozinhaLúcia CarvalhoAlameda dos Canàrios, 891São Paulo05487-020Brazil
70Santé GourmetJonas BergulfsenErling Skakkes gate 78Stavern4110Norway
81Tradição HipermercadosAnabela DominguesAv. Inês de Castro, 414São Paulo05634-030Brazil
86Die Wandernde KuhRita MüllerAdenauerallee 900Stuttgart70563Germany
89White Clover MarketsKarl Jablonski305 – 14th Ave. S. Suite 3BSeattle98128USA

 

Contoh Kondisi IN

Gunakan kondisi IN untuk melakukan filter data berdasarkan beberapa nilai tertentu. Contoh di bawah ini akan menampilkan data dengan kondisi nilai kolom City bernilai ‘Paris’ atau ‘London’.

SELECT * FROM Customers
WHERE City IN ('Paris','London');
CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
4Around the HornThomas Hardy120 Hanover Sq.LondonWA1 1DPUK
11B’s BeveragesVictoria AshworthFauntleroy CircusLondonEC2 5NTUK
16Consolidated HoldingsElizabeth BrownBerkeley Gardens 12 BreweryLondonWX1 6LTUK
19Eastern ConnectionAnn Devon35 King GeorgeLondonWX3 6FWUK
53North/SouthSimon CrowtherSouth House 300 QueensbridgeLondonSW7 1RZUK
57Paris spécialitésMarie Bertrand265, boulevard CharonneParis75012France
72Seven Seas ImportsHari Kumar90 Wadhurst Rd.LondonOX15 4NBUK
74Spécialités du mondeDominique Perrier25, rue LauristonParis75016France

Menggabungkan Kondisi

Query SELECT WHERE juga bisa menggunakan gabungan beberapa kondisi sekaligus. Penggabungan kondisi bisa menggunakan keyword AND atau keyword OR. Penggabungan dengan menggunakan AND menyebabkan satu baris data lolos filter apabila memenuhi semua kondisi yang digabungkan. Penggabungan dengan menggunakan OR menyebabkan satu baris data lolos filter apabila memenuhi salah satu kondisi yang digabungkan.

Berikut adalah format penggabungan kondisi dengan menggunakan AND.

SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3 ...;

Berikut adalah format penggabungan kondisi dengan menggunakan OR.

SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;

Kita juga dapat menggunakan NOT untuk melakukan negasi pada kondisi. Dengan menggunakan keyword NOT maka satu baris data akan lolos filter apabila tidak memenuhi kondisi yang diberikan. Di bawah ini adalah format pemakaian kondisi NOT.

SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;

Contoh Penggunaan AND

Contoh di bawah ini hanya menampilkan data dengan kondisi nilai kolom Country sama dengan ‘Germany’ dan kolom City sama dengan ‘Berlin’.

SELECT * FROM Customers
WHERE Country='Germany' AND City='Berlin';
CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
1Alfreds FutterkisteMaria AndersObere Str. 57Berlin12209Germany

 

Contoh Penggunaan OR

Contoh di bawah ini menampilkan data dengan kondisi nilai kolom City sama dengan ‘Berlin’ atau sama dengan ‘Munchen’.

SELECT * FROM Customers
WHERE City='Berlin' OR City='München';
CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
1Alfreds FutterkisteMaria AndersObere Str. 57Berlin12209Germany
25FrankenversandPeter FrankenBerliner Platz 43München80805Germany

Contoh di bawah ini menampilkan data dengan kondisi nilai kolom Country sama dengan ‘Germany’ atau sama dengan ‘Spain’.

SELECT * FROM Customers
WHERE Country='Germany' OR Country='Spain';
CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
1Alfreds FutterkisteMaria AndersObere Str. 57Berlin12209Germany
6Blauer See DelikatessenHanna MoosForsterstr. 57Mannheim68306Germany
8Bólido Comidas preparadasMartín SommerC/ Araquil, 67Madrid28023Spain
17Drachenblut DelikatessendSven OttliebWalserweg 21Aachen52066Germany
22FISSA Fabrica Inter. Salchichas S.A.Diego RoelC/ Moralzarzal, 86Madrid28034Spain
25FrankenversandPeter FrankenBerliner Platz 43München80805Germany
29Galería del gastrónomoEduardo SaavedraRambla de Cataluña, 23Barcelona08022Spain
30Godos Cocina TípicaJosé Pedro FreyreC/ Romero, 33Sevilla41101Spain
39Königlich EssenPhilip CramerMaubelstr. 90Brandenburg14776Germany
44Lehmanns MarktstandRenate MessnerMagazinweg 7Frankfurt a.M.60528Germany
52Morgenstern GesundkostAlexander FeuerHeerstr. 22Leipzig04179Germany
56Ottilies KäseladenHenriette PfalzheimMehrheimerstr. 369Köln50739Germany
63QUICK-StopHorst KlossTaucherstraße 10Cunewalde01307Germany
69Romero y tomilloAlejandra CaminoGran Vía, 1Madrid28001Spain
79Toms SpezialitätenKarin JosephsLuisenstr. 48Münster44087Germany
86Die Wandernde KuhRita MüllerAdenauerallee 900Stuttgart70563Germany

 

Contoh Penggunaan NOT

Contoh di bawah ini menampilkan data dengan kondisi nilai kolom Country tidak sama dengan ‘Germany’.

SELECT * FROM Customers
WHERE NOT Country='Germany';
CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
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
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
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
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
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
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
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
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
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
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
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

 

Contoh Penggunaan AND Dan OR

Contoh di bawah ini menampilkan data dengan kondisi nilai kolom Country sama dengan ‘Germany’ dan nilai kolom City sama dengan ‘Berlin’ atau sama dengan ‘Munchen’. Kondisi OR dijadikan satu kondisi tersendiri kemudian digabungkan dengan kondisi AND.

SELECT * FROM Customers
WHERE Country='Germany' AND (City='Berlin' OR City='München');
CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
1Alfreds FutterkisteMaria AndersObere Str. 57Berlin12209Germany
25FrankenversandPeter FrankenBerliner Platz 43München80805Germany

 

Contoh Penggunaan AND Dan NOT

Contoh di bawah ini menampilkan data dengan kondisi nilai kolom Contry tidak sama dengan ‘Germany’ dan juga tidak sama dengan ‘USA’.

SELECT * FROM Customers
WHERE NOT Country='Germany' AND NOT Country='USA';
CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
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
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
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
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
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
37Hungry Owl All-Night GrocersPatricia McKenna8 Johnstown RoadCorkIreland
38Island TradingHelen BennettGarden House Crowther WayCowesPO31 7PJUK
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
46LILA-SupermercadoCarlos GonzálezCarrera 52 con Ave. Bolívar #65-98 Llano LargoBarquisimeto3508Venezuela
47LINO-DelicatesesFelipe IzquierdoAve. 5 de Mayo PorlamarI. de Margarita4980Venezuela
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
53North/SouthSimon CrowtherSouth House 300 QueensbridgeLondonSW7 1RZUK
54Océano Atlántico Ltda.Yvonne MoncadaIng. Gustavo Moncada 8585 Piso 20-ABuenos Aires1010Argentina
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
64Rancho grandeSergio GutiérrezAv. del Libertador 900Buenos Aires1010Argentina
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
72Seven Seas ImportsHari Kumar90 Wadhurst Rd.LondonOX15 4NBUK
73Simons bistroJytte PetersenVinbæltet 34København1734Denmark
74Spécialités du mondeDominique Perrier25, rue LauristonParis75016France
76Suprêmes délicesPascale CartrainBoulevard Tirou, 255CharleroiB-6000Belgium
80Tortuga RestauranteMiguel Angel PaolinoAvda. Azteca 123México D.F.05033Mexico
81Tradição HipermercadosAnabela DominguesAv. Inês de Castro, 414São Paulo05634-030Brazil
83VaffeljernetPalle IbsenSmagsløget 45Århus8200Denmark
84Victuailles en stockMary Saveley2, rue du CommerceLyon69004France
85Vins et alcools ChevalierPaul Henriot59 rue de l’AbbayeReims51100France
87Wartian HerkkuPirkko KoskitaloTorikatu 38Oulu90110Finland
88Wellington ImportadoraPaula ParenteRua do Mercado, 12Resende08737-363Brazil
90Wilman KalaMatti KarttunenKeskuskatu 45Helsinki21240Finland
91WolskiZbyszekul. Filtrowa 68Walla01-012Poland

Mengurutkan Hasil Query

Hasil query juga bisa diurutkan berdasarkan kriteria dan kolom tertentu. Gunakan keyword ORDER BY untuk mengurutkan hasil query. Pengurutan bisa dari nilai paling kecil sampai nilai paling besar (ASC) atau bisa juga dari nilai paling besar sampai nilai paling kecil (DESC). Secara default pengurutan memakai mode ASC. Berikut adalah format query dengan menggunakan pengurutan.

SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;

Pengurutan juga bisa dilakukan pada kolom dengan tipe data text. Setiap database mempunyai aturan sendiri untuk pengurutan text.

 

Contoh Penggunaan ORDER BY

Contoh di bawah ini menampilkan data dengan mengurutkan kolom Country.

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

 

Contoh Penggunaan ORDER BY DESC

Contoh di bawah ini menampilkan data dengan mengurutkan kolom Country dari nilai paling besar sampai nilai paling kecil.

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

 

Contoh Mengurutkan Beberapa Kolom

Contoh di bawah ini menampilkan data dengan mengurutkan kolom Country dan CustomerName.

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

 

Contoh di bawah ini menampilkan data dengan mengurutkan kolom Country dan mengurutkan kolom CustomerName dari nilai paling besar sampai nilai paling kecil.

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

Tutorial sebelumnya : Membuat Tabel Database
Tutorial setelahnya : Perintah Insert SQL
Semua Tutorial SQL : Tutorial SQL

Tinggalkan Balasan

Keranjang Belanja0
Keranjang belanja kosong ...
0