Documentation complète : https://sql.sh/cours/select
La commande SELECT permet de lire des données depuis une base de données.
Syntaxe générale
Légende
[ ] : optionnel
| : ou
Passer le curseur de la souris sur les mots clé pour obtenir des informations …
SELECTSELECTsélection de données depuis une base [ DISTINCTDISTINCTrenvoie uniquement des valeurs distinctes (différentes) ] **toutes les colonnes | colonne1 [, colonne2, colonne3, …] | fonction d’agrégation
FROMFROMorigine (tables) de la sélection table1 [table2, table3, …]
[ ( [ INNERINNER JOINintersection (défaut) | LEFTLEFT JOINintersection + table de gauche | RIGHTRIGHT JOINintersection + table de droite | FULLFULL JOINunion ] JOINJOINjonction de deux tables table2 ONONcritère de jonction table1.colonne_i = table2.colonne_j )
[ JOIN table3 ON table_i.colonne_k = table3.colonne_l …] ]
[ WHEREWHEREfiltrage des enregistrements : extraction des seuls enregistrements respectant la condition condition]
[ GROUP BYGROUP BYgroupement des résultats par colonne(s) : utilisé uniquement avec les fonctions d'agrégation (COUNT, MAX, MIN, SUM, AVG) colonne1 [, colonne2, …]
[ HAVINGHAVINGfiltrage (à utiliser pour les fonctions d'agrégation) condition ] ]
[ ORDER BYORDER BYtri des résultats selon une ou plusieurs colonnes (ordre croissant par défaut) colonne1 [ ASCASCordre croissant | DESCDESCordre décroissant ] [, colonne2 [ ASC | DESC ], …]
Conditions
colonne ==renvoie la condition vrai lorsque le contenu de la colonne contient la valeur spécifiée valeur : renvoie la condition vrai lorsque le contenu de la colonne contient la valeur spécifiée
colonne LIKE motif : renvoie la condition vrai lorsque le motif est trouvé dans la colonne.
Le motif est une chaîne de caractères pouvant contenir :
-
- % un nombre quelconque de caractères
- _ un unique caractère
Exemples :
-
- « Z% » = toutes les chaînes de caractères commençant par « Z »
- « _z% » = toutes les chaînes de caractères ayant un « z » comme deuxième caractère
- …
colonne [NOT] IN liste
Une liste est :
-
- un ensemble de valeurs, entre parenthèses : (valeur1, valeur2, …)
- le résultat d’une autre requête SELECT : (SELECT … FROM …)
Une liste est toujours écrite entre parenthèses !
condition1 AND condition2
condition1 OR condition2
Fonctions d’agrégation
MIN(colonne) : valeur minimale dans la colonne pour les enregistrements sélectionnés
MAX(colonne) : valeur maximale dans la colonne pour les enregistrements sélectionnés
COUNT(* | colonne) : nombre d’enregistrements sélectionnés (les enregistrements NULL de la colonne ne sont pas comptés ; * = toutes les colonnes)
AVG(colonne) : moyenne des valeurs de la colonne pour les enregistrements sélectionnés
SUM(colonne) : somme des valeurs de la colonne pour les enregistrements sélectionnés
Exemples
Il est possible de s’exercer aux requêtes SELECT en ligne grâce au Try-SQL Editor
Table : Customers (91 enregistrements)
| 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 |
| … |
… |
… |
… |
… |
… |
… |
Table : Products (77 enregistrements)
| ProductID |
ProductName |
SupplierID |
CategoryID |
Unit |
Price |
| 1 |
Chais |
1 |
1 |
10 boxes x 20 bags |
18 |
| 2 |
Chang |
1 |
1 |
24 – 12 oz bottles |
19 |
| 3 |
Aniseed Syrup |
1 |
2 |
12 – 550 ml bottles |
10 |
| 4 |
Chef Anton’s Cajun Seasoning |
2 |
2 |
48 – 6 oz jars |
22 |
| 5 |
Chef Anton’s Gumbo Mix |
2 |
2 |
36 boxes |
21.35 |
| … |
… |
… |
… |
… |
… |
Table : Orders (196 enregistrements)
| OrderID |
CustomerID |
EmployeeID |
OrderDate |
ShipperID |
| 10308 |
2 |
7 |
1996-09-18 |
3 |
| 10309 |
37 |
3 |
1996-09-19 |
1 |
| 10310 |
77 |
8 |
1996-09-20 |
2 |
SELECT *
FROM Customers;
Voir le résultat
| 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 |
SELECT Country
FROM Customers;
Voir le résultat
91 enregistrements : certains pays apparaissent plusieurs fois.
| 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 |
SELECT DISTINCT Country
FROM Customers;
Voir le résultat
Il n’y a plus qu’une seule occurrence de chaque pays.
| Country |
| Argentina |
| Austria |
| Belgium |
| Brazil |
| Canada |
| Denmark |
| Finland |
| France |
| Germany |
| Ireland |
| Italy |
| Mexico |
| Norway |
| Poland |
| Portugal |
| Spain |
| Sweden |
| Switzerland |
| UK |
| USA |
| Venezuela |
SELECT * FROM Customers
WHERE Country='Mexico';
Voir le résultat
| CustomerID |
CustomerName |
ContactName |
Address |
City |
PostalCode |
Country |
| 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 |
| 13 |
Centro comercial Moctezuma |
Francisco Chang |
Sierras de Granada 9993 |
México D.F. |
05022 |
Mexico |
| 58 |
Pericles Comidas clásicas |
Guillermo Fernández |
Calle Dr. Jorge Cash 321 |
México D.F. |
05033 |
Mexico |
| 80 |
Tortuga Restaurante |
Miguel Angel Paolino |
Avda. Azteca 123 |
México D.F. |
05033 |
Mexico |
SELECT * FROM Customers
WHERE Country='Germany' AND City='Berlin';
Voir le résultat
| CustomerID |
CustomerName |
ContactName |
Address |
City |
PostalCode |
Country |
| 1 |
Alfreds Futterkiste |
Maria Anders |
Obere Str. 57 |
Berlin |
12209 |
Germany |
SELECT * FROM Customers
ORDER BY Country DESC;
Voir le résultat
| CustomerID |
CustomerName |
ContactName |
Address |
City |
PostalCode |
Country |
| 47 |
LINO-Delicateses |
Felipe Izquierdo |
Ave. 5 de Mayo Porlamar |
I. de Margarita |
4980 |
Venezuela |
| 33 |
GROSELLA-Restaurante |
Manuel Pereira |
5ª Ave. Los Palos Grandes |
Caracas |
1081 |
Venezuela |
| 35 |
HILARIÓN-Abastos |
Carlos Hernández |
Carrera 22 con Ave. Carlos Soublette #8-35 |
San Cristóbal |
5022 |
Venezuela |
| 46 |
LILA-Supermercado |
Carlos González |
Carrera 52 con Ave. Bolívar #65-98 Llano Largo |
Barquisimeto |
3508 |
Venezuela |
| 32 |
Great Lakes Food Market |
Howard Snyder |
2732 Baker Blvd. |
Eugene |
97403 |
USA |
| 43 |
Lazy K Kountry Store |
John Steel |
12 Orchestra Terrace |
Walla Walla |
99362 |
USA |
| 75 |
Split Rail Beer & Ale |
Art Braunschweiger |
P.O. Box 555 |
Lander |
82520 |
USA |
| 55 |
Old World Delicatessen |
Rene Phillips |
2743 Bering St. |
Anchorage |
99508 |
USA |
| 77 |
The Big Cheese |
Liz Nixon |
89 Jefferson Way Suite 2 |
Portland |
97201 |
USA |
| 71 |
Save-a-lot Markets |
Jose Pavarotti |
187 Suffolk Ln. |
Boise |
83720 |
USA |
| 78 |
The Cracker Box |
Liu Wong |
55 Grizzly Peak Rd. |
Butte |
59801 |
USA |
| 65 |
Rattlesnake Canyon Grocery |
Paula Wilson |
2817 Milton Dr. |
Albuquerque |
87110 |
USA |
| 89 |
White Clover Markets |
Karl Jablonski |
305 – 14th Ave. S. Suite 3B |
Seattle |
98128 |
USA |
| 82 |
Trail’s Head Gourmet Provisioners |
Helvetius Nagy |
722 DaVinci Blvd. |
Kirkland |
98034 |
USA |
| 48 |
Lonesome Pine Restaurant |
Fran Wilson |
89 Chiaroscuro Rd. |
Portland |
97219 |
USA |
| 36 |
Hungry Coyote Import Store |
Yoshi Latimer |
City Center Plaza 516 Main St. |
Elgin |
97827 |
USA |
| 45 |
Let’s Stop N Shop |
Jaime Yorres |
87 Polk St. Suite 5 |
San Francisco |
94117 |
USA |
| 38 |
Island Trading |
Helen Bennett |
Garden House Crowther Way |
Cowes |
PO31 7PJ |
UK |
| 19 |
Eastern Connection |
Ann Devon |
35 King George |
London |
WX3 6FW |
UK |
| 16 |
Consolidated Holdings |
Elizabeth Brown |
Berkeley Gardens 12 Brewery |
London |
WX1 6LT |
UK |
| 53 |
North/South |
Simon Crowther |
South House 300 Queensbridge |
London |
SW7 1RZ |
UK |
| 11 |
B’s Beverages |
Victoria Ashworth |
Fauntleroy Circus |
London |
EC2 5NT |
UK |
| 72 |
Seven Seas Imports |
Hari Kumar |
90 Wadhurst Rd. |
London |
OX15 4NB |
UK |
| 4 |
Around the Horn |
Thomas Hardy |
120 Hanover Sq. |
London |
WA1 1DP |
UK |
| 68 |
Richter Supermarkt |
Michael Holz |
Grenzacherweg 237 |
Genève |
1203 |
Switzerland |
| 14 |
Chop-suey Chinese |
Yang Wang |
Hauptstr. 29 |
Bern |
3012 |
Switzerland |
| 5 |
Berglunds snabbköp |
Christina Berglund |
Berguvsvägen 8 |
Luleå |
S-958 22 |
Sweden |
| 24 |
Folk och fä HB |
Maria Larsson |
Åkergatan 24 |
Bräcke |
S-844 67 |
Sweden |
| 69 |
Romero y tomillo |
Alejandra Camino |
Gran Vía, 1 |
Madrid |
28001 |
Spain |
| 30 |
Godos Cocina Típica |
José Pedro Freyre |
C/ Romero, 33 |
Sevilla |
41101 |
Spain |
| 22 |
FISSA Fabrica Inter. Salchichas S.A. |
Diego Roel |
C/ Moralzarzal, 86 |
Madrid |
28034 |
Spain |
| 8 |
Bólido Comidas preparadas |
Martín Sommer |
C/ Araquil, 67 |
Madrid |
28023 |
Spain |
| 29 |
Galería del gastrónomo |
Eduardo Saavedra |
Rambla de Cataluña, 23 |
Barcelona |
08022 |
Spain |
| 28 |
Furia Bacalhau e Frutos do Mar |
Lino Rodriguez |
Jardim das rosas n. 32 |
Lisboa |
1675 |
Portugal |
| 60 |
Princesa Isabel Vinhoss |
Isabel de Castro |
Estrada da saúde n. 58 |
Lisboa |
1756 |
Portugal |
| 91 |
Wolski |
Zbyszek |
ul. Filtrowa 68 |
Walla |
01-012 |
Poland |
| 70 |
Santé Gourmet |
Jonas Bergulfsen |
Erling Skakkes gate 78 |
Stavern |
4110 |
Norway |
| 13 |
Centro comercial Moctezuma |
Francisco Chang |
Sierras de Granada 9993 |
México D.F. |
05022 |
Mexico |
| 58 |
Pericles Comidas clásicas |
Guillermo Fernández |
Calle Dr. Jorge Cash 321 |
México D.F. |
05033 |
Mexico |
| 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 |
| 80 |
Tortuga Restaurante |
Miguel Angel Paolino |
Avda. Azteca 123 |
México D.F. |
05033 |
Mexico |
| 66 |
Reggiani Caseifici |
Maurizio Moroni |
Strada Provinciale 124 |
Reggio Emilia |
42100 |
Italy |
| 27 |
Franchi S.p.A. |
Paolo Accorti |
Via Monte Bianco 34 |
Torino |
10100 |
Italy |
| 49 |
Magazzini Alimentari Riuniti |
Giovanni Rovelli |
Via Ludovico il Moro 22 |
Bergamo |
24100 |
Italy |
| 37 |
Hungry Owl All-Night Grocers |
Patricia McKenna |
8 Johnstown Road |
Cork |
|
Ireland |
| 39 |
Königlich Essen |
Philip Cramer |
Maubelstr. 90 |
Brandenburg |
14776 |
Germany |
| 25 |
Frankenversand |
Peter Franken |
Berliner Platz 43 |
München |
80805 |
Germany |
| 17 |
Drachenblut Delikatessend |
Sven Ottlieb |
Walserweg 21 |
Aachen |
52066 |
Germany |
| 6 |
Blauer See Delikatessen |
Hanna Moos |
Forsterstr. 57 |
Mannheim |
68306 |
Germany |
| 56 |
Ottilies Käseladen |
Henriette Pfalzheim |
Mehrheimerstr. 369 |
Köln |
50739 |
Germany |
| 1 |
Alfreds Futterkiste |
Maria Anders |
Obere Str. 57 |
Berlin |
12209 |
Germany |
| 63 |
QUICK-Stop |
Horst Kloss |
Taucherstraße 10 |
Cunewalde |
01307 |
Germany |
| 86 |
Die Wandernde Kuh |
Rita Müller |
Adenauerallee 900 |
Stuttgart |
70563 |
Germany |
| 44 |
Lehmanns Marktstand |
Renate Messner |
Magazinweg 7 |
Frankfurt a.M. |
60528 |
Germany |
| 79 |
Toms Spezialitäten |
Karin Josephs |
Luisenstr. 48 |
Münster |
44087 |
Germany |
| 52 |
Morgenstern Gesundkost |
Alexander Feuer |
Heerstr. 22 |
Leipzig |
04179 |
Germany |
| 74 |
Spécialités du monde |
Dominique Perrier |
25, rue Lauriston |
Paris |
75016 |
France |
| 18 |
Du monde entier |
Janine Labrune |
67, rue des Cinquante Otages |
Nantes |
44000 |
France |
| 9 |
Bon app’ |
Laurence Lebihans |
12, rue des Bouchers |
Marseille |
13008 |
France |
| 41 |
La maison d’Asie |
Annette Roulet |
1 rue Alsace-Lorraine |
Toulouse |
31000 |
France |
| 23 |
Folies gourmandes |
Martine Rancé |
184, chaussée de Tournai |
Lille |
59000 |
France |
| 7 |
Blondel père et fils |
Frédérique Citeaux |
24, place Kléber |
Strasbourg |
67000 |
France |
| 26 |
France restauration |
Carine Schmitt |
54, rue Royale |
Nantes |
44000 |
France |
| 57 |
Paris spécialités |
Marie Bertrand |
265, boulevard Charonne |
Paris |
75012 |
France |
| 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 |
| 40 |
La corne d’abondance |
Daniel Tonini |
67, avenue de l’Europe |
Versailles |
78000 |
France |
| 90 |
Wilman Kala |
Matti Karttunen |
Keskuskatu 45 |
Helsinki |
21240 |
Finland |
| 87 |
Wartian Herkku |
Pirkko Koskitalo |
Torikatu 38 |
Oulu |
90110 |
Finland |
| 73 |
Simons bistro |
Jytte Petersen |
Vinbæltet 34 |
København |
1734 |
Denmark |
| 83 |
Vaffeljernet |
Palle Ibsen |
Smagsløget 45 |
Århus |
8200 |
Denmark |
| 51 |
Mère Paillarde |
Jean Fresnière |
43 rue St. Laurent |
Montréal |
H1J 1C3 |
Canada |
| 42 |
Laughing Bacchus Wine Cellars |
Yoshi Tannamuri |
1900 Oak St. |
Vancouver |
V3F 2K1 |
Canada |
| 10 |
Bottom-Dollar Marketse |
Elizabeth Lincoln |
23 Tsawassen Blvd. |
Tsawassen |
T2F 8M4 |
Canada |
| 62 |
Queen Cozinha |
Lúcia Carvalho |
Alameda dos Canàrios, 891 |
São Paulo |
05487-020 |
Brazil |
| 81 |
Tradição Hipermercados |
Anabela Domingues |
Av. Inês de Castro, 414 |
São Paulo |
05634-030 |
Brazil |
| 15 |
Comércio Mineiro |
Pedro Afonso |
Av. dos Lusíadas, 23 |
São Paulo |
05432-043 |
Brazil |
| 67 |
Ricardo Adocicados |
Janete Limeira |
Av. Copacabana, 267 |
Rio de Janeiro |
02389-890 |
Brazil |
| 21 |
Familia Arquibaldo |
Aria Cruz |
Rua Orós, 92 |
São Paulo |
05442-030 |
Brazil |
| 61 |
Que Delícia |
Bernardo Batista |
Rua da Panificadora, 12 |
Rio de Janeiro |
02389-673 |
Brazil |
| 31 |
Gourmet Lanchonetes |
André Fonseca |
Av. Brasil, 442 |
Campinas |
04876-786 |
Brazil |
| 34 |
Hanari Carnes |
Mario Pontes |
Rua do Paço, 67 |
Rio de Janeiro |
05454-876 |
Brazil |
| 88 |
Wellington Importadora |
Paula Parente |
Rua do Mercado, 12 |
Resende |
08737-363 |
Brazil |
| 76 |
Suprêmes délices |
Pascale Cartrain |
Boulevard Tirou, 255 |
Charleroi |
B-6000 |
Belgium |
| 50 |
Maison Dewey |
Catherine Dewey |
Rue Joseph-Bens 532 |
Bruxelles |
B-1180 |
Belgium |
| 59 |
Piccolo und mehr |
Georg Pipps |
Geislweg 14 |
Salzburg |
5020 |
Austria |
| 20 |
Ernst Handel |
Roland Mendel |
Kirchgasse 6 |
Graz |
8010 |
Austria |
| 12 |
Cactus Comidas para llevar |
Patricio Simpson |
Cerrito 333 |
Buenos Aires |
1010 |
Argentina |
| 64 |
Rancho grande |
Sergio Gutiérrez |
Av. del Libertador 900 |
Buenos Aires |
1010 |
Argentina |
| 54 |
Océano Atlántico Ltda. |
Yvonne Moncada |
Ing. Gustavo Moncada 8585 Piso 20-A |
Buenos Aires |
1010 |
Argentina |
SELECT COUNT(ProductID)
FROM Products;
SELECT * FROM Customers
WHERE CustomerName LIKE 'a%';
Voir le résultat
Les Consommateurs dont le nom commence par la lettre ‘a’.
| 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 |
SELECT * FROM Customers
WHERE CustomerName LIKE '_r%';
Voir le résultat
Les Consommateurs dont le nom possède la lettre ‘r’ en deuxième position.
| CustomerID |
CustomerName |
ContactName |
Address |
City |
PostalCode |
Country |
| 4 |
Around the Horn |
Thomas Hardy |
120 Hanover Sq. |
London |
WA1 1DP |
UK |
| 17 |
Drachenblut Delikatessend |
Sven Ottlieb |
Walserweg 21 |
Aachen |
52066 |
Germany |
| 20 |
Ernst Handel |
Roland Mendel |
Kirchgasse 6 |
Graz |
8010 |
Austria |
| 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 |
| 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 |
| 60 |
Princesa Isabel Vinhoss |
Isabel de Castro |
Estrada da saúde n. 58 |
Lisboa |
1756 |
Portugal |
| 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 |
SELECT Orders.OrderID, Customers.CustomerName
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
Voir le résultat
| OrderID |
CustomerName |
| 10308 |
Ana Trujillo Emparedados y helados |
| 10365 |
Antonio Moreno Taquería |
| 10383 |
Around the Horn |
| 10355 |
Around the Horn |
| 10278 |
Berglunds snabbköp |
| 10280 |
Berglunds snabbköp |
| 10384 |
Berglunds snabbköp |
| 10436 |
Blondel père et fils |
| 10297 |
Blondel père et fils |
| 10360 |
Blondel père et fils |
| 10265 |
Blondel père et fils |
| 10326 |
Bólido Comidas preparadas |
| 10331 |
Bon app’ |
| 10340 |
Bon app’ |
| 10362 |
Bon app’ |
| 10389 |
Bottom-Dollar Marketse |
| 10410 |
Bottom-Dollar Marketse |
| 10411 |
Bottom-Dollar Marketse |
| 10431 |
Bottom-Dollar Marketse |
| 10289 |
B’s Beverages |
| 10259 |
Centro comercial Moctezuma |
| 10370 |
Chop-suey Chinese |
| 10254 |
Chop-suey Chinese |
| 10290 |
Comércio Mineiro |
| 10435 |
Consolidated Holdings |
| 10391 |
Drachenblut Delikatessend |
| 10363 |
Drachenblut Delikatessend |
| 10311 |
Du monde entier |
| 10364 |
Eastern Connection |
| 10400 |
Eastern Connection |
| 10368 |
Ernst Handel |
| 10403 |
Ernst Handel |
| 10390 |
Ernst Handel |
| 10263 |
Ernst Handel |
| 10442 |
Ernst Handel |
| 10258 |
Ernst Handel |
| 10382 |
Ernst Handel |
| 10430 |
Ernst Handel |
| 10351 |
Ernst Handel |
| 10402 |
Ernst Handel |
| 10386 |
Familia Arquibaldo |
| 10347 |
Familia Arquibaldo |
| 10414 |
Familia Arquibaldo |
| 10408 |
Folies gourmandes |
| 10378 |
Folk och fä HB |
| 10327 |
Folk och fä HB |
| 10264 |
Folk och fä HB |
| 10434 |
Folk och fä HB |
| 10337 |
Frankenversand |
| 10396 |
Frankenversand |
| 10267 |
Frankenversand |
| 10342 |
Frankenversand |
| 10422 |
Franchi S.p.A. |
| 10328 |
Furia Bacalhau e Frutos do Mar |
| 10352 |
Furia Bacalhau e Frutos do Mar |
| 10366 |
Galería del gastrónomo |
| 10426 |
Galería del gastrónomo |
| 10303 |
Godos Cocina Típica |
| 10423 |
Gourmet Lanchonetes |
| 10268 |
GROSELLA-Restaurante |
| 10253 |
Hanari Carnes |
| 10250 |
Hanari Carnes |
| 10257 |
HILARIÓN-Abastos |
| 10395 |
HILARIÓN-Abastos |
| 10415 |
Hungry Coyote Import Store |
| 10375 |
Hungry Coyote Import Store |
| 10394 |
Hungry Coyote Import Store |
| 10380 |
Hungry Owl All-Night Grocers |
| 10309 |
Hungry Owl All-Night Grocers |
| 10429 |
Hungry Owl All-Night Grocers |
| 10298 |
Hungry Owl All-Night Grocers |
| 10373 |
Hungry Owl All-Night Grocers |
| 10335 |
Hungry Owl All-Night Grocers |
| 10315 |
Island Trading |
| 10318 |
Island Trading |
| 10321 |
Island Trading |
| 10323 |
Königlich Essen |
| 10325 |
Königlich Essen |
| 10413 |
La maison d’Asie |
| 10371 |
La maison d’Asie |
| 10358 |
La maison d’Asie |
| 10350 |
La maison d’Asie |
| 10425 |
La maison d’Asie |
| 10284 |
Lehmanns Marktstand |
| 10343 |
Lehmanns Marktstand |
| 10279 |
Lehmanns Marktstand |
| 10381 |
LILA-Supermercado |
| 10283 |
LILA-Supermercado |
| 10357 |
LILA-Supermercado |
| 10296 |
LILA-Supermercado |
| 10330 |
LILA-Supermercado |
| 10405 |
LINO-Delicateses |
| 10307 |
Lonesome Pine Restaurant |
| 10317 |
Lonesome Pine Restaurant |
| 10300 |
Magazzini Alimentari Riuniti |
| 10404 |
Magazzini Alimentari Riuniti |
| 10275 |
Magazzini Alimentari Riuniti |
| 10332 |
Mère Paillarde |
| 10339 |
Mère Paillarde |
| 10424 |
Mère Paillarde |
| 10439 |
Mère Paillarde |
| 10376 |
Mère Paillarde |
| 10277 |
Morgenstern Gesundkost |
| 10409 |
Océano Atlántico Ltda. |
| 10260 |
Old World Delicatessen |
| 10305 |
Old World Delicatessen |
| 10338 |
Old World Delicatessen |
| 10441 |
Old World Delicatessen |
| 10407 |
Ottilies Käseladen |
| 10354 |
Pericles Comidas clásicas |
| 10322 |
Pericles Comidas clásicas |
| 10353 |
Piccolo und mehr |
| 10392 |
Piccolo und mehr |
| 10427 |
Piccolo und mehr |
| 10397 |
Princesa Isabel Vinhoss |
| 10433 |
Princesa Isabel Vinhoss |
| 10336 |
Princesa Isabel Vinhoss |
| 10421 |
Que Delícia |
| 10261 |
Que Delícia |
| 10379 |
Que Delícia |
| 10291 |
Que Delícia |
| 10406 |
Queen Cozinha |
| 10372 |
Queen Cozinha |
| 10418 |
QUICK-Stop |
| 10273 |
QUICK-Stop |
| 10361 |
QUICK-Stop |
| 10285 |
QUICK-Stop |
| 10313 |
QUICK-Stop |
| 10286 |
QUICK-Stop |
| 10345 |
QUICK-Stop |
| 10262 |
Rattlesnake Canyon Grocery |
| 10272 |
Rattlesnake Canyon Grocery |
| 10294 |
Rattlesnake Canyon Grocery |
| 10346 |
Rattlesnake Canyon Grocery |
| 10401 |
Rattlesnake Canyon Grocery |
| 10314 |
Rattlesnake Canyon Grocery |
| 10316 |
Rattlesnake Canyon Grocery |
| 10288 |
Reggiani Caseifici |
| 10428 |
Reggiani Caseifici |
| 10443 |
Reggiani Caseifici |
| 10287 |
Ricardo Adocicados |
| 10299 |
Ricardo Adocicados |
| 10419 |
Richter Supermarkt |
| 10255 |
Richter Supermarkt |
| 10281 |
Romero y tomillo |
| 10282 |
Romero y tomillo |
| 10306 |
Romero y tomillo |
| 10387 |
Santé Gourmet |
| 10398 |
Save-a-lot Markets |
| 10324 |
Save-a-lot Markets |
| 10393 |
Save-a-lot Markets |
| 10440 |
Save-a-lot Markets |
| 10359 |
Seven Seas Imports |
| 10388 |
Seven Seas Imports |
| 10377 |
Seven Seas Imports |
| 10417 |
Simons bistro |
| 10341 |
Simons bistro |
| 10432 |
Split Rail Beer & Ale |
| 10369 |
Split Rail Beer & Ale |
| 10271 |
Split Rail Beer & Ale |
| 10329 |
Split Rail Beer & Ale |
| 10349 |
Split Rail Beer & Ale |
| 10385 |
Split Rail Beer & Ale |
| 10302 |
Suprêmes délices |
| 10252 |
Suprêmes délices |
| 10310 |
The Big Cheese |
| 10438 |
Toms Spezialitäten |
| 10304 |
Tortuga Restaurante |
| 10319 |
Tortuga Restaurante |
| 10293 |
Tortuga Restaurante |
| 10276 |
Tortuga Restaurante |
| 10249 |
Tradição Hipermercados |
| 10292 |
Tradição Hipermercados |
| 10399 |
Vaffeljernet |
| 10367 |
Vaffeljernet |
| 10334 |
Victuailles en stock |
| 10251 |
Victuailles en stock |
| 10274 |
Vins et alcools Chevalier |
| 10295 |
Vins et alcools Chevalier |
| 10356 |
Die Wandernde Kuh |
| 10301 |
Die Wandernde Kuh |
| 10348 |
Die Wandernde Kuh |
| 10312 |
Die Wandernde Kuh |
| 10412 |
Wartian Herkku |
| 10437 |
Wartian Herkku |
| 10320 |
Wartian Herkku |
| 10266 |
Wartian Herkku |
| 10333 |
Wartian Herkku |
| 10270 |
Wartian Herkku |
| 10416 |
Wartian Herkku |
| 10256 |
Wellington Importadora |
| 10420 |
Wellington Importadora |
| 10269 |
White Clover Markets |
| 10344 |
White Clover Markets |
| 10248 |
Wilman Kala |
| 10374 |
Wolski |
SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID
ORDER BY Customers.CustomerName;
Voir le résultat
| CustomerName |
OrderID |
| Alfreds Futterkiste |
|
| Ana Trujillo Emparedados y helados |
10308 |
| Antonio Moreno Taquería |
10365 |
| Around the Horn |
10383 |
| Around the Horn |
10355 |
| Berglunds snabbköp |
10278 |
| Berglunds snabbköp |
10280 |
| Berglunds snabbköp |
10384 |
| Blauer See Delikatessen |
|
| Blondel père et fils |
10360 |
| Blondel père et fils |
10297 |
| Blondel père et fils |
10436 |
| Blondel père et fils |
10265 |
| Bólido Comidas preparadas |
10326 |
| Bon app’ |
10331 |
| Bon app’ |
10340 |
| Bon app’ |
10362 |
| Bottom-Dollar Marketse |
10411 |
| Bottom-Dollar Marketse |
10431 |
| Bottom-Dollar Marketse |
10389 |
| Bottom-Dollar Marketse |
10410 |
| B’s Beverages |
10289 |
| Cactus Comidas para llevar |
|
| Centro comercial Moctezuma |
10259 |
| Chop-suey Chinese |
10370 |
| Chop-suey Chinese |
10254 |
| Comércio Mineiro |
10290 |
| Consolidated Holdings |
10435 |
| Die Wandernde Kuh |
10301 |
| Die Wandernde Kuh |
10312 |
| Die Wandernde Kuh |
10348 |
| Die Wandernde Kuh |
10356 |
| Drachenblut Delikatessend |
10391 |
| Drachenblut Delikatessend |
10363 |
| Du monde entier |
10311 |
| Eastern Connection |
10364 |
| Eastern Connection |
10400 |
| Ernst Handel |
10382 |
| Ernst Handel |
10351 |
| Ernst Handel |
10403 |
| Ernst Handel |
10430 |
| Ernst Handel |
10402 |
| Ernst Handel |
10258 |
| Ernst Handel |
10442 |
| Ernst Handel |
10390 |
| Ernst Handel |
10368 |
| Ernst Handel |
10263 |
| Familia Arquibaldo |
10386 |
| Familia Arquibaldo |
10347 |
| Familia Arquibaldo |
10414 |
| FISSA Fabrica Inter. Salchichas S.A. |
|
| Folies gourmandes |
10408 |
| Folk och fä HB |
10264 |
| Folk och fä HB |
10327 |
| Folk och fä HB |
10378 |
| Folk och fä HB |
10434 |
| France restauration |
|
| Franchi S.p.A. |
10422 |
| Frankenversand |
10337 |
| Frankenversand |
10396 |
| Frankenversand |
10267 |
| Frankenversand |
10342 |
| Furia Bacalhau e Frutos do Mar |
10328 |
| Furia Bacalhau e Frutos do Mar |
10352 |
| Galería del gastrónomo |
10426 |
| Galería del gastrónomo |
10366 |
| Godos Cocina Típica |
10303 |
| Gourmet Lanchonetes |
10423 |
| Great Lakes Food Market |
|
| GROSELLA-Restaurante |
10268 |
| Hanari Carnes |
10253 |
| Hanari Carnes |
10250 |
| HILARIÓN-Abastos |
10257 |
| HILARIÓN-Abastos |
10395 |
| Hungry Coyote Import Store |
10415 |
| Hungry Coyote Import Store |
10375 |
| Hungry Coyote Import Store |
10394 |
| Hungry Owl All-Night Grocers |
10373 |
| Hungry Owl All-Night Grocers |
10298 |
| Hungry Owl All-Night Grocers |
10335 |
| Hungry Owl All-Night Grocers |
10309 |
| Hungry Owl All-Night Grocers |
10380 |
| Hungry Owl All-Night Grocers |
10429 |
| Island Trading |
10315 |
| Island Trading |
10318 |
| Island Trading |
10321 |
| Königlich Essen |
10323 |
| Königlich Essen |
10325 |
| La corne d’abondance |
|
| La maison d’Asie |
10425 |
| La maison d’Asie |
10413 |
| La maison d’Asie |
10371 |
| La maison d’Asie |
10358 |
| La maison d’Asie |
10350 |
| Laughing Bacchus Wine Cellars |
|
| Lazy K Kountry Store |
|
| Lehmanns Marktstand |
10284 |
| Lehmanns Marktstand |
10343 |
| Lehmanns Marktstand |
10279 |
| Let’s Stop N Shop |
|
| LILA-Supermercado |
10381 |
| LILA-Supermercado |
10283 |
| LILA-Supermercado |
10357 |
| LILA-Supermercado |
10296 |
| LILA-Supermercado |
10330 |
| LINO-Delicateses |
10405 |
| Lonesome Pine Restaurant |
10307 |
| Lonesome Pine Restaurant |
10317 |
| Magazzini Alimentari Riuniti |
10275 |
| Magazzini Alimentari Riuniti |
10404 |
| Magazzini Alimentari Riuniti |
10300 |
| Maison Dewey |
|
| Mère Paillarde |
10332 |
| Mère Paillarde |
10339 |
| Mère Paillarde |
10424 |
| Mère Paillarde |
10439 |
| Mère Paillarde |
10376 |
| Morgenstern Gesundkost |
10277 |
| North/South |
|
| Océano Atlántico Ltda. |
10409 |
| Old World Delicatessen |
10305 |
| Old World Delicatessen |
10338 |
| Old World Delicatessen |
10260 |
| Old World Delicatessen |
10441 |
| Ottilies Käseladen |
10407 |
| Paris spécialités |
|
| Pericles Comidas clásicas |
10354 |
| Pericles Comidas clásicas |
10322 |
| Piccolo und mehr |
10353 |
| Piccolo und mehr |
10392 |
| Piccolo und mehr |
10427 |
| Princesa Isabel Vinhoss |
10397 |
| Princesa Isabel Vinhoss |
10433 |
| Princesa Isabel Vinhoss |
10336 |
| Que Delícia |
10421 |
| Que Delícia |
10291 |
| Que Delícia |
10261 |
| Que Delícia |
10379 |
| Queen Cozinha |
10406 |
| Queen Cozinha |
10372 |
| QUICK-Stop |
10418 |
| QUICK-Stop |
10273 |
| QUICK-Stop |
10361 |
| QUICK-Stop |
10285 |
| QUICK-Stop |
10313 |
| QUICK-Stop |
10286 |
| QUICK-Stop |
10345 |
| Rancho grande |
|
| Rattlesnake Canyon Grocery |
10316 |
| Rattlesnake Canyon Grocery |
10314 |
| Rattlesnake Canyon Grocery |
10401 |
| Rattlesnake Canyon Grocery |
10346 |
| Rattlesnake Canyon Grocery |
10294 |
| Rattlesnake Canyon Grocery |
10262 |
| Rattlesnake Canyon Grocery |
10272 |
| Reggiani Caseifici |
10288 |
| Reggiani Caseifici |
10428 |
| Reggiani Caseifici |
10443 |
| Ricardo Adocicados |
10287 |
| Ricardo Adocicados |
10299 |
| Richter Supermarkt |
10419 |
| Richter Supermarkt |
10255 |
| Romero y tomillo |
10282 |
| Romero y tomillo |
10306 |
| Romero y tomillo |
10281 |
| Santé Gourmet |
10387 |
| Save-a-lot Markets |
10398 |
| Save-a-lot Markets |
10324 |
| Save-a-lot Markets |
10393 |
| Save-a-lot Markets |
10440 |
| Seven Seas Imports |
10359 |
| Seven Seas Imports |
10388 |
| Seven Seas Imports |
10377 |
| Simons bistro |
10341 |
| Simons bistro |
10417 |
| Spécialités du monde |
|
| Split Rail Beer & Ale |
10369 |
| Split Rail Beer & Ale |
10271 |
| Split Rail Beer & Ale |
10329 |
| Split Rail Beer & Ale |
10349 |
| Split Rail Beer & Ale |
10385 |
| Split Rail Beer & Ale |
10432 |
| Suprêmes délices |
10302 |
| Suprêmes délices |
10252 |
| The Big Cheese |
10310 |
| The Cracker Box |
|
| Toms Spezialitäten |
10438 |
| Tortuga Restaurante |
10276 |
| Tortuga Restaurante |
10293 |
| Tortuga Restaurante |
10304 |
| Tortuga Restaurante |
10319 |
| Tradição Hipermercados |
10249 |
| Tradição Hipermercados |
10292 |
| Trail’s Head Gourmet Provisioners |
|
| Vaffeljernet |
10399 |
| Vaffeljernet |
10367 |
| Victuailles en stock |
10334 |
| Victuailles en stock |
10251 |
| Vins et alcools Chevalier |
10274 |
| Vins et alcools Chevalier |
10295 |
| Wartian Herkku |
10412 |
| Wartian Herkku |
10416 |
| Wartian Herkku |
10270 |
| Wartian Herkku |
10333 |
| Wartian Herkku |
10266 |
| Wartian Herkku |
10437 |
| Wartian Herkku |
10320 |
| Wellington Importadora |
10256 |
| Wellington Importadora |
10420 |
| White Clover Markets |
10269 |
| White Clover Markets |
10344 |
| Wilman Kala |
10248 |
| Wolski |
10374 |
Sources : https://fr.wikipedia.org/wiki/Base_de_données_relationnelle
https://www.w3schools.com/sql/default.asp