Skip to Content
Imparare SQL, 3a edizione
book

Imparare SQL, 3a edizione

by Alan Beaulieu
April 2025
Intermediate to advanced
380 pages
10h 10m
Italian
O'Reilly Media, Inc.
Book available
Content preview from Imparare SQL, 3a edizione

Appendice B. Soluzioni agli esercizi

Capitolo 3

Esercizio 3-1

Recupera l'ID dell'attore, il nome e il cognome di tutti gli attori. Ordina per cognome e poi per nome.

mysql> SELECT actor_id, first_name, last_name
    -> FROM actor
    -> ORDER BY 3,2;
+----------+-------------+--------------+
| actor_id | first_name  | last_name    |
+----------+-------------+--------------+
|       58 | CHRISTIAN   | AKROYD       |
|      182 | DEBBIE      | AKROYD       |
|       92 | KIRSTEN     | AKROYD       |
|      118 | CUBA        | ALLEN        |
|      145 | KIM         | ALLEN        |
|      194 | MERYL       | ALLEN        |
...
|       13 | UMA         | WOOD         |
|       63 | CAMERON     | WRAY         |
|      111 | CAMERON     | ZELLWEGER    |
|      186 | JULIA       | ZELLWEGER    |
|       85 | MINNIE      | ZELLWEGER    |
+----------+-------------+--------------+
200 rows in set (0.02 sec)

Esercizio 3-2

Recupera l'ID dell'attore, il nome e il cognome di tutti gli attori il cui cognome è uguale a 'WILLIAMS' o 'DAVIS'.

 mysql> SELECT actor_id, first_name, last_name     -> FROM actor     -> WHERE last_name = 'WILLIAMS' OR last_name = 'DAVIS'; +----------+------------+-----------+ | actor_id | first_name | last_name | +----------+------------+-----------+ |        4 | JENNIFER   | DAVIS     | |      101 | SUSAN      | DAVIS     | |      110 | SUSAN      | DAVIS     | |       72 | SEAN       | WILLIAMS  | |      137 | MORGAN     | WILLIAMS  | |      172 | GROUCHO    ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

SQL per l'analisi dei dati

SQL per l'analisi dei dati

Cathy Tanimura

Publisher Resources

ISBN: 9798341643390