mysql select from author ----------- ------------------ AUTHOR_ID NAME

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
mysql> select * from author;
+-----------+------------------+
| AUTHOR_ID | NAME |
+-----------+------------------+
| 1 | Taras Shevchenko |
| 2 | Vasylko |
+-----------+------------------+
2 rows in set (0.00 sec)
mysql> select * from book;
+---------+-----------+-------------------+-------+
| BOOK_ID | AUTHOR_ID | NAME | TYPE |
+---------+-----------+-------------------+-------+
| 1 | 1 | Kobzar | poem |
| 2 | 1 | Roman N1 | roman |
| 3 | 2 | Toreodore | roman |
| 4 | 1 | The Roman N155678 | roman |
+---------+-----------+-------------------+-------+
4 rows in set (0.00 sec)
mysql> select author.NAME, book.NAME from book left join author on book.AUTHOR_ID=author.AUTHOR_ID where TYPE='roman';
+------------------+-------------------+
| NAME | NAME |
+------------------+-------------------+
| Taras Shevchenko | Roman N1 |
| Vasylko | Toreodore |
| Taras Shevchenko | The Roman N155678 |
+------------------+-------------------+
3 rows in set (0.00 sec)
mysql> select book.NAME, author.NAME from book, author where book.AUTHOR_ID=author.AUTHOR_ID and book.TYPE='roman';
+-------------------+------------------+
| NAME | NAME |
+-------------------+------------------+
| Roman N1 | Taras Shevchenko |
| Toreodore | Vasylko |
| The Roman N155678 | Taras Shevchenko |
+-------------------+------------------+
3 rows in set (0.00 sec)
mysql> select t.NAME, p.NAME from book t, author p where p.AUTHOR_ID=t.AUTHOR_ID and t.TYPE='roman';
+-------------------+------------------+
| NAME | NAME |
+-------------------+------------------+
| Roman N1 | Taras Shevchenko |
| Toreodore | Vasylko |
| The Roman N155678 | Taras Shevchenko |
+-------------------+------------------+
3 rows in set (0.00 sec)
mysql>
mysql>
mysql> select book.NAME as Nazva_Knyzhky, author.NAME as Avtor from book, author where book.AUTHOR_ID=author.AUTHOR_ID and book.TYPE='roman';
+-------------------+------------------+
| Nazva_Knyzhky | Avtor |
+-------------------+------------------+
| Roman N1 | Taras Shevchenko |
| Toreodore | Vasylko |
| The Roman N155678 | Taras Shevchenko |
+-------------------+------------------+
3 rows in set (0.00 sec)