Database Reference
In-Depth Information
SQL join operation with the example
database
Now, we will try to check which maker is common between both tables and their mod-
els by using the join SQL command as follows:
[Hadoop.testdomain:21000] > select
automobiles.make, automobiles.model,
motorcycles.make,motorcycles.model from
automobiles JOIN motorcycles USING (make);
Query finished, fetching results ...
+-------+-------+-------+---------+
| make | model | make | model |
+-------+-------+-------+---------+
| BMW | M3 | BMW | R1200RT |
| BMW | X5 | BMW | R1200RT |
| Honda | Civic | Honda | VFR400 |
| Honda | Civic | Honda | CB900 |
| Honda | Civic | Honda | CBR600 |
+-------+-------+-------+---------+
Returned 5 row(s) in 0.40s
Now, we will insert automakers from both the automobiles and motorcycles
tables into the automakers table by using the Insert Overwrite and Insert
Into SQL statements as follows:
[Hadoop.testdomain:21000] > INSERT OVERWRITE
TABLE automakers SELECT distinct(make) from
automobiles;
Inserted 10 rows in 2.00s
[Hadoop.testdomain:21000] > INSERT INTO TABLE
automakers SELECT distinct(make) from
motorcycles;
Inserted 10 rows in 0.71s
Search WWH ::




Custom Search