Select all the data from the products, including all the data for each product's manufacturer.
| SELECT code, name, price, manufacturer FROM products
| SELECT code, name FROM manufacturer
| RENAME code manufacturer
| RENAME name manufacturername
| JOIN manufacturer
10 rows 0 msec
| SELECT code, name FROM manufacturer
| RENAME code manufacturer
| RENAME name manufacturername
| JOIN manufacturer
10 rows 0 msec
code | name | price | manufacturer | manufacturername |
---|---|---|---|---|
1 | Hard drive | 240 | 5 | Fujitsu |
2 | Memory | 120 | 6 | Winchester |
3 | ZIP drive | 150 | 4 | Iomega |
4 | Floppy disk | 5 | 6 | Winchester |
5 | Monitor | 240 | 1 | Sony |
6 | DVD drive | 180 | 2 | Creative Labs |
7 | CD drive | 90 | 2 | Creative Labs |
8 | Printer | 270 | 3 | Hewlett Packard |
9 | Toner cartridge | 66 | 3 | Hewlett Packard |
10 | DVD burner | 180 | 2 | Creative Labs |
You must specify the fields on SELECT, you cannot use *.
The JOIN statement works on a common column. Use RENAME to create the common column and to avoid name conflicts.