Alias adalah nama sementara pada hasil query yang menggantikan nama kolom atau nama tabel. Nama sementara ini tidak akan mengganti nama kolom atau nama tabel yang sesungguhnya pada database. Nama sementara ini (atau alias) hanya digunakan pada hasil query saja. Fungsi alias adalah untuk memudahkan pembacaan hasil query pada kasus-kasus tertentu.
Di bawah ini adalah format alias untuk nama kolom, alias_name akan menjadi nama alias pengganti nama kolom column_name pada hasil query.
SELECT column_name AS alias_name
FROM table_name;
Di bawah ini adalah format alias untuk nama tabel, alias_name akan menjadi nama alias pengganti nama tabel table_name pada hasil query.
SELECT column_name(s)
FROM table_name AS alias_name;
Data Awal Untuk Contoh Query
Semua contoh query SQL pada artikel ini dijalankan kepada tabel Customers dan Orders. Data tabel Customers dan Orders terlampir di bawah ini.
Tabel Customers
CustomerID | CustomerName | ContactName | Address | City | PostalCode | Country |
---|---|---|---|---|---|---|
1 | Alfreds Futterkiste | Maria Anders | Obere Str. 57 | Berlin | 12209 | Germany |
2 | Ana Trujillo Emparedados y helados | Ana Trujillo | Avda. de la Constitución 2222 | México D.F. | 05021 | Mexico |
3 | Antonio Moreno Taquería | Antonio Moreno | Mataderos 2312 | México D.F. | 05023 | Mexico |
4 | Around the Horn | Thomas Hardy | 120 Hanover Sq. | London | WA1 1DP | UK |
5 | Berglunds snabbköp | Christina Berglund | Berguvsvägen 8 | Luleå | S-958 22 | Sweden |
6 | Blauer See Delikatessen | Hanna Moos | Forsterstr. 57 | Mannheim | 68306 | Germany |
7 | Blondel père et fils | Frédérique Citeaux | 24, place Kléber | Strasbourg | 67000 | France |
8 | Bólido Comidas preparadas | Martín Sommer | C/ Araquil, 67 | Madrid | 28023 | Spain |
9 | 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 Orders
OrderID | CustomerID | EmployeeID | OrderDate | ShipperID |
---|---|---|---|---|
10248 | 90 | 5 | 7/4/1996 | 3 |
10249 | 81 | 6 | 7/5/1996 | 1 |
10250 | 34 | 4 | 7/8/1996 | 2 |
10251 | 84 | 3 | 7/8/1996 | 1 |
10252 | 76 | 4 | 7/9/1996 | 2 |
10253 | 34 | 3 | 7/10/1996 | 2 |
10254 | 14 | 5 | 7/11/1996 | 2 |
10255 | 68 | 9 | 7/12/1996 | 3 |
10256 | 88 | 3 | 7/15/1996 | 2 |
10257 | 35 | 4 | 7/16/1996 | 3 |
10258 | 20 | 1 | 7/17/1996 | 1 |
10259 | 13 | 4 | 7/18/1996 | 3 |
10260 | 55 | 4 | 7/19/1996 | 1 |
10261 | 61 | 4 | 7/19/1996 | 2 |
10262 | 65 | 8 | 7/22/1996 | 3 |
10263 | 20 | 9 | 7/23/1996 | 3 |
10264 | 24 | 6 | 7/24/1996 | 3 |
10265 | 7 | 2 | 7/25/1996 | 1 |
10266 | 87 | 3 | 7/26/1996 | 3 |
10267 | 25 | 4 | 7/29/1996 | 1 |
10268 | 33 | 8 | 7/30/1996 | 3 |
10269 | 89 | 5 | 7/31/1996 | 1 |
10270 | 87 | 1 | 8/1/1996 | 1 |
10271 | 75 | 6 | 8/1/1996 | 2 |
10272 | 65 | 6 | 8/2/1996 | 2 |
10273 | 63 | 3 | 8/5/1996 | 3 |
10274 | 85 | 6 | 8/6/1996 | 1 |
10275 | 49 | 1 | 8/7/1996 | 1 |
10276 | 80 | 8 | 8/8/1996 | 3 |
10277 | 52 | 2 | 8/9/1996 | 3 |
10278 | 5 | 8 | 8/12/1996 | 2 |
10279 | 44 | 8 | 8/13/1996 | 2 |
10280 | 5 | 2 | 8/14/1996 | 1 |
10281 | 69 | 4 | 8/14/1996 | 1 |
10282 | 69 | 4 | 8/15/1996 | 1 |
10283 | 46 | 3 | 8/16/1996 | 3 |
10284 | 44 | 4 | 8/19/1996 | 1 |
10285 | 63 | 1 | 8/20/1996 | 2 |
10286 | 63 | 8 | 8/21/1996 | 3 |
10287 | 67 | 8 | 8/22/1996 | 3 |
10288 | 66 | 4 | 8/23/1996 | 1 |
10289 | 11 | 7 | 8/26/1996 | 3 |
10290 | 15 | 8 | 8/27/1996 | 1 |
10291 | 61 | 6 | 8/27/1996 | 2 |
10292 | 81 | 1 | 8/28/1996 | 2 |
10293 | 80 | 1 | 8/29/1996 | 3 |
10294 | 65 | 4 | 8/30/1996 | 2 |
10295 | 85 | 2 | 9/2/1996 | 2 |
10296 | 46 | 6 | 9/3/1996 | 1 |
10297 | 7 | 5 | 9/4/1996 | 2 |
10298 | 37 | 6 | 9/5/1996 | 2 |
10299 | 67 | 4 | 9/6/1996 | 2 |
10300 | 49 | 2 | 9/9/1996 | 2 |
10301 | 86 | 8 | 9/9/1996 | 2 |
10302 | 76 | 4 | 9/10/1996 | 2 |
10303 | 30 | 7 | 9/11/1996 | 2 |
10304 | 80 | 1 | 9/12/1996 | 2 |
10305 | 55 | 8 | 9/13/1996 | 3 |
10306 | 69 | 1 | 9/16/1996 | 3 |
10307 | 48 | 2 | 9/17/1996 | 2 |
10308 | 2 | 7 | 9/18/1996 | 3 |
10309 | 37 | 3 | 9/19/1996 | 1 |
10310 | 77 | 8 | 9/20/1996 | 2 |
10311 | 18 | 1 | 9/20/1996 | 3 |
10312 | 86 | 2 | 9/23/1996 | 2 |
10313 | 63 | 2 | 9/24/1996 | 2 |
10314 | 65 | 1 | 9/25/1996 | 2 |
10315 | 38 | 4 | 9/26/1996 | 2 |
10316 | 65 | 1 | 9/27/1996 | 3 |
10317 | 48 | 6 | 9/30/1996 | 1 |
10318 | 38 | 8 | 10/1/1996 | 2 |
10319 | 80 | 7 | 10/2/1996 | 3 |
10320 | 87 | 5 | 10/3/1996 | 3 |
10321 | 38 | 3 | 10/3/1996 | 2 |
10322 | 58 | 7 | 10/4/1996 | 3 |
10323 | 39 | 4 | 10/7/1996 | 1 |
10324 | 71 | 9 | 10/8/1996 | 1 |
10325 | 39 | 1 | 10/9/1996 | 3 |
10326 | 8 | 4 | 10/10/1996 | 2 |
10327 | 24 | 2 | 10/11/1996 | 1 |
10328 | 28 | 4 | 10/14/1996 | 3 |
10329 | 75 | 4 | 10/15/1996 | 2 |
10330 | 46 | 3 | 10/16/1996 | 1 |
10331 | 9 | 9 | 10/16/1996 | 1 |
10332 | 51 | 3 | 10/17/1996 | 2 |
10333 | 87 | 5 | 10/18/1996 | 3 |
10334 | 84 | 8 | 10/21/1996 | 2 |
10335 | 37 | 7 | 10/22/1996 | 2 |
10336 | 60 | 7 | 10/23/1996 | 2 |
10337 | 25 | 4 | 10/24/1996 | 3 |
10338 | 55 | 4 | 10/25/1996 | 3 |
10339 | 51 | 2 | 10/28/1996 | 2 |
10340 | 9 | 1 | 10/29/1996 | 3 |
10341 | 73 | 7 | 10/29/1996 | 3 |
10342 | 25 | 4 | 10/30/1996 | 2 |
10343 | 44 | 4 | 10/31/1996 | 1 |
10344 | 89 | 4 | 11/1/1996 | 2 |
10345 | 63 | 2 | 11/4/1996 | 2 |
10346 | 65 | 3 | 11/5/1996 | 3 |
10347 | 21 | 4 | 11/6/1996 | 3 |
10348 | 86 | 4 | 11/7/1996 | 2 |
10349 | 75 | 7 | 11/8/1996 | 1 |
10350 | 41 | 6 | 11/11/1996 | 2 |
10351 | 20 | 1 | 11/11/1996 | 1 |
10352 | 28 | 3 | 11/12/1996 | 3 |
10353 | 59 | 7 | 11/13/1996 | 3 |
10354 | 58 | 8 | 11/14/1996 | 3 |
10355 | 4 | 6 | 11/15/1996 | 1 |
10356 | 86 | 6 | 11/18/1996 | 2 |
10357 | 46 | 1 | 11/19/1996 | 3 |
10358 | 41 | 5 | 11/20/1996 | 1 |
10359 | 72 | 5 | 11/21/1996 | 3 |
10360 | 7 | 4 | 11/22/1996 | 3 |
10361 | 63 | 1 | 11/22/1996 | 2 |
10362 | 9 | 3 | 11/25/1996 | 1 |
10363 | 17 | 4 | 11/26/1996 | 3 |
10364 | 19 | 1 | 11/26/1996 | 1 |
10365 | 3 | 3 | 11/27/1996 | 2 |
10366 | 29 | 8 | 11/28/1996 | 2 |
10367 | 83 | 7 | 11/28/1996 | 3 |
10368 | 20 | 2 | 11/29/1996 | 2 |
10369 | 75 | 8 | 12/2/1996 | 2 |
10370 | 14 | 6 | 12/3/1996 | 2 |
10371 | 41 | 1 | 12/3/1996 | 1 |
10372 | 62 | 5 | 12/4/1996 | 2 |
10373 | 37 | 4 | 12/5/1996 | 3 |
10374 | 91 | 1 | 12/5/1996 | 3 |
10375 | 36 | 3 | 12/6/1996 | 2 |
10376 | 51 | 1 | 12/9/1996 | 2 |
10377 | 72 | 1 | 12/9/1996 | 3 |
10378 | 24 | 5 | 12/10/1996 | 3 |
10379 | 61 | 2 | 12/11/1996 | 1 |
10380 | 37 | 8 | 12/12/1996 | 3 |
10381 | 46 | 3 | 12/12/1996 | 3 |
10382 | 20 | 4 | 12/13/1996 | 1 |
10383 | 4 | 8 | 12/16/1996 | 3 |
10384 | 5 | 3 | 12/16/1996 | 3 |
10385 | 75 | 1 | 12/17/1996 | 2 |
10386 | 21 | 9 | 12/18/1996 | 3 |
10387 | 70 | 1 | 12/18/1996 | 2 |
10388 | 72 | 2 | 12/19/1996 | 1 |
10389 | 10 | 4 | 12/20/1996 | 2 |
10390 | 20 | 6 | 12/23/1996 | 1 |
10391 | 17 | 3 | 12/23/1996 | 3 |
10392 | 59 | 2 | 12/24/1996 | 3 |
10393 | 71 | 1 | 12/25/1996 | 3 |
10394 | 36 | 1 | 12/25/1996 | 3 |
10395 | 35 | 6 | 12/26/1996 | 1 |
10396 | 25 | 1 | 12/27/1996 | 3 |
10397 | 60 | 5 | 12/27/1996 | 1 |
10398 | 71 | 2 | 12/30/1996 | 3 |
10399 | 83 | 8 | 12/31/1996 | 3 |
10400 | 19 | 1 | 1/1/1997 | 3 |
10401 | 65 | 1 | 1/1/1997 | 1 |
10402 | 20 | 8 | 1/2/1997 | 2 |
10403 | 20 | 4 | 1/3/1997 | 3 |
10404 | 49 | 2 | 1/3/1997 | 1 |
10405 | 47 | 1 | 1/6/1997 | 1 |
10406 | 62 | 7 | 1/7/1997 | 1 |
10407 | 56 | 2 | 1/7/1997 | 2 |
10408 | 23 | 8 | 1/8/1997 | 1 |
10409 | 54 | 3 | 1/9/1997 | 1 |
10410 | 10 | 3 | 1/10/1997 | 3 |
10411 | 10 | 9 | 1/10/1997 | 3 |
10412 | 87 | 8 | 1/13/1997 | 2 |
10413 | 41 | 3 | 1/14/1997 | 2 |
10414 | 21 | 2 | 1/14/1997 | 3 |
10415 | 36 | 3 | 1/15/1997 | 1 |
10416 | 87 | 8 | 1/16/1997 | 3 |
10417 | 73 | 4 | 1/16/1997 | 3 |
10418 | 63 | 4 | 1/17/1997 | 1 |
10419 | 68 | 4 | 1/20/1997 | 2 |
10420 | 88 | 3 | 1/21/1997 | 1 |
10421 | 61 | 8 | 1/21/1997 | 1 |
10422 | 27 | 2 | 1/22/1997 | 1 |
10423 | 31 | 6 | 1/23/1997 | 3 |
10424 | 51 | 7 | 1/23/1997 | 2 |
10425 | 41 | 6 | 1/24/1997 | 2 |
10426 | 29 | 4 | 1/27/1997 | 1 |
10427 | 59 | 4 | 1/27/1997 | 2 |
10428 | 66 | 7 | 1/28/1997 | 1 |
10429 | 37 | 3 | 1/29/1997 | 2 |
10430 | 20 | 4 | 1/30/1997 | 1 |
10431 | 10 | 4 | 1/30/1997 | 2 |
10432 | 75 | 3 | 1/31/1997 | 2 |
10433 | 60 | 3 | 2/3/1997 | 3 |
10434 | 24 | 3 | 2/3/1997 | 2 |
10435 | 16 | 8 | 2/4/1997 | 2 |
10436 | 7 | 3 | 2/5/1997 | 2 |
10437 | 87 | 8 | 2/5/1997 | 1 |
10438 | 79 | 3 | 2/6/1997 | 2 |
10439 | 51 | 6 | 2/7/1997 | 3 |
10440 | 71 | 4 | 2/10/1997 | 2 |
10441 | 55 | 3 | 2/10/1997 | 2 |
10442 | 20 | 3 | 2/11/1997 | 2 |
10443 | 66 | 8 | 2/12/1997 | 1 |
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.
Contoh Alias Kolom
Contoh di bawah ini akan menampilkan data dari tabel Customers. Nama kolom CustomerID akan diganti menjadi nama alias ID. Nama kolom CustomerName akan diganti menjadi nama alias Customer.
SELECT CustomerID AS ID, CustomerName AS Customer
FROM Customers;
ID | Customer |
---|---|
2 | Ana Trujillo Emparedados y helados |
3 | Antonio Moreno Taquería |
4 | Around the Horn |
5 | Berglunds snabbköp |
6 | Blauer See Delikatessen |
7 | Blondel père et fils |
8 | Bólido Comidas preparadas |
9 | Bon app’ |
10 | Bottom-Dollar Marketse |
11 | B’s Beverages |
12 | Cactus Comidas para llevar |
13 | Centro comercial Moctezuma |
14 | Chop-suey Chinese |
15 | Comércio Mineiro |
16 | Consolidated Holdings |
17 | Drachenblut Delikatessend |
18 | Du monde entier |
19 | Eastern Connection |
20 | Ernst Handel |
21 | Familia Arquibaldo |
22 | FISSA Fabrica Inter. Salchichas S.A. |
23 | Folies gourmandes |
24 | Folk och fä HB |
25 | Frankenversand |
26 | France restauration |
27 | Franchi S.p.A. |
28 | Furia Bacalhau e Frutos do Mar |
29 | Galería del gastrónomo |
30 | Godos Cocina Típica |
31 | Gourmet Lanchonetes |
32 | Great Lakes Food Market |
33 | GROSELLA-Restaurante |
34 | Hanari Carnes |
35 | HILARIÓN-Abastos |
36 | Hungry Coyote Import Store |
37 | Hungry Owl All-Night Grocers |
38 | Island Trading |
39 | Königlich Essen |
40 | La corne d’abondance |
41 | La maison d’Asie |
42 | Laughing Bacchus Wine Cellars |
43 | Lazy K Kountry Store |
44 | Lehmanns Marktstand |
45 | Let’s Stop N Shop |
46 | LILA-Supermercado |
47 | LINO-Delicateses |
48 | Lonesome Pine Restaurant |
49 | Magazzini Alimentari Riuniti |
50 | Maison Dewey |
51 | Mère Paillarde |
52 | Morgenstern Gesundkost |
53 | North/South |
54 | Océano Atlántico Ltda. |
55 | Old World Delicatessen |
56 | Ottilies Käseladen |
57 | Paris spécialités |
58 | Pericles Comidas clásicas |
59 | Piccolo und mehr |
60 | Princesa Isabel Vinhoss |
61 | Que Delícia |
62 | Queen Cozinha |
63 | QUICK-Stop |
64 | Rancho grande |
65 | Rattlesnake Canyon Grocery |
66 | Reggiani Caseifici |
67 | Ricardo Adocicados |
68 | Richter Supermarkt |
69 | Romero y tomillo |
70 | Santé Gourmet |
71 | Save-a-lot Markets |
72 | Seven Seas Imports |
73 | Simons bistro |
74 | Spécialités du monde |
75 | Split Rail Beer & Ale |
76 | Suprêmes délices |
77 | The Big Cheese |
78 | The Cracker Box |
79 | Toms Spezialitäten |
80 | Tortuga Restaurante |
81 | Tradição Hipermercados |
82 | Trail’s Head Gourmet Provisioners |
83 | Vaffeljernet |
84 | Victuailles en stock |
85 | Vins et alcools Chevalier |
86 | Die Wandernde Kuh |
87 | Wartian Herkku |
88 | Wellington Importadora |
89 | White Clover Markets |
90 | Wilman Kala |
91 | Wolski |
92 | Cardinal |
Contoh di bawah ini memperlihatkan alias kolom yang terdiri dari dua kata, untuk keperluan ini gunakan [] atau double quote.
SELECT CustomerName AS Customer, ContactName AS [Contact Person]
FROM Customers;
Customer | Contact Person |
---|---|
Ana Trujillo Emparedados y helados | Ana Trujillo |
Antonio Moreno Taquería | Antonio Moreno |
Around the Horn | Thomas Hardy |
Berglunds snabbköp | Christina Berglund |
Blauer See Delikatessen | Hanna Moos |
Blondel père et fils | Frédérique Citeaux |
Bólido Comidas preparadas | Martín Sommer |
Bon app’ | Laurence Lebihans |
Bottom-Dollar Marketse | Elizabeth Lincoln |
B’s Beverages | Victoria Ashworth |
Cactus Comidas para llevar | Patricio Simpson |
Centro comercial Moctezuma | Francisco Chang |
Chop-suey Chinese | Yang Wang |
Comércio Mineiro | Pedro Afonso |
Consolidated Holdings | Elizabeth Brown |
Drachenblut Delikatessend | Sven Ottlieb |
Du monde entier | Janine Labrune |
Eastern Connection | Ann Devon |
Ernst Handel | Roland Mendel |
Familia Arquibaldo | Aria Cruz |
FISSA Fabrica Inter. Salchichas S.A. | Diego Roel |
Folies gourmandes | Martine Rancé |
Folk och fä HB | Maria Larsson |
Frankenversand | Peter Franken |
France restauration | Carine Schmitt |
Franchi S.p.A. | Paolo Accorti |
Furia Bacalhau e Frutos do Mar | Lino Rodriguez |
Galería del gastrónomo | Eduardo Saavedra |
Godos Cocina Típica | José Pedro Freyre |
Gourmet Lanchonetes | André Fonseca |
Great Lakes Food Market | Howard Snyder |
GROSELLA-Restaurante | Manuel Pereira |
Hanari Carnes | Mario Pontes |
HILARIÓN-Abastos | Carlos Hernández |
Hungry Coyote Import Store | Yoshi Latimer |
Hungry Owl All-Night Grocers | Patricia McKenna |
Island Trading | Helen Bennett |
Königlich Essen | Philip Cramer |
La corne d’abondance | Daniel Tonini |
La maison d’Asie | Annette Roulet |
Laughing Bacchus Wine Cellars | Yoshi Tannamuri |
Lazy K Kountry Store | John Steel |
Lehmanns Marktstand | Renate Messner |
Let’s Stop N Shop | Jaime Yorres |
LILA-Supermercado | Carlos González |
LINO-Delicateses | Felipe Izquierdo |
Lonesome Pine Restaurant | Fran Wilson |
Magazzini Alimentari Riuniti | Giovanni Rovelli |
Maison Dewey | Catherine Dewey |
Mère Paillarde | Jean Fresnière |
Morgenstern Gesundkost | Alexander Feuer |
North/South | Simon Crowther |
Océano Atlántico Ltda. | Yvonne Moncada |
Old World Delicatessen | Rene Phillips |
Ottilies Käseladen | Henriette Pfalzheim |
Paris spécialités | Marie Bertrand |
Pericles Comidas clásicas | Guillermo Fernández |
Piccolo und mehr | Georg Pipps |
Princesa Isabel Vinhoss | Isabel de Castro |
Que Delícia | Bernardo Batista |
Queen Cozinha | Lúcia Carvalho |
QUICK-Stop | Horst Kloss |
Rancho grande | Sergio Gutiérrez |
Rattlesnake Canyon Grocery | Paula Wilson |
Reggiani Caseifici | Maurizio Moroni |
Ricardo Adocicados | Janete Limeira |
Richter Supermarkt | Michael Holz |
Romero y tomillo | Alejandra Camino |
Santé Gourmet | Jonas Bergulfsen |
Save-a-lot Markets | Jose Pavarotti |
Seven Seas Imports | Hari Kumar |
Simons bistro | Jytte Petersen |
Spécialités du monde | Dominique Perrier |
Split Rail Beer & Ale | Art Braunschweiger |
Suprêmes délices | Pascale Cartrain |
The Big Cheese | Liz Nixon |
The Cracker Box | Liu Wong |
Toms Spezialitäten | Karin Josephs |
Tortuga Restaurante | Miguel Angel Paolino |
Tradição Hipermercados | Anabela Domingues |
Trail’s Head Gourmet Provisioners | Helvetius Nagy |
Vaffeljernet | Palle Ibsen |
Victuailles en stock | Mary Saveley |
Vins et alcools Chevalier | Paul Henriot |
Die Wandernde Kuh | Rita Müller |
Wartian Herkku | Pirkko Koskitalo |
Wellington Importadora | Paula Parente |
White Clover Markets | Karl Jablonski |
Wilman Kala | Matti Karttunen |
Wolski | Zbyszek |
Cardinal | null |
Contoh Alias Tabel
Contoh di bawah ini akan menampilkan data dari tabel Customers dan Orders. Nama tabel Customers diganti menjadi nama alias c. Nama tabel Orders diganti menjadi nama alias o.
SELECT o.OrderID, o.OrderDate, c.CustomerName
FROM Customers AS c, Orders AS o
WHERE c.CustomerName='Around the Horn' AND c.CustomerID=o.CustomerID;
OrderID | OrderDate | CustomerName |
---|---|---|
10355 | 1996-11-15 | Around the Horn |
10383 | 1996-12-16 | Around the Horn |
Apabila contoh sebelumnya tidak menggunakan alias maka akan dituliskan seperti contoh di bawah ini.
SELECT Orders.OrderID, Orders.OrderDate, Customers.CustomerName
FROM Customers, Orders
WHERE Customers.CustomerName='Around the Horn' AND Customers.CustomerID=Orders.CustomerID;
OrderID | OrderDate | CustomerName |
---|---|---|
10355 | 1996-11-15 | Around the Horn |
10383 | 1996-12-16 | Around the Horn |
Tutorial sebelumnya : SQL In Dan Between
Tutorial setelahnya : SQL Group By
Semua Tutorial SQL : Tutorial SQL