0% found this document useful (0 votes)
5 views

SQL Multiple Tables

sql notes

Uploaded by

Divyansh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
5 views

SQL Multiple Tables

sql notes

Uploaded by

Divyansh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
1828724, 10:38 PM Learn SOL: Multiple Tales Cheatshect | Codecademy Cheatsheets / Learn SQL Multiple Tables Outer Join {An outer join will combine raws from different tables even i ifthe join condition is not met. Ina LEFT JOIN , every row in the lef table is returned in the result set, and ifthe join condition is not met, then NULL values are used to filin the columns from the right table. KITk Clause ‘The WITH clause stores the result of query ina temporary table ( temporary_movies )using an alas. Multiple temporary tables can be defined Instance of the WITH keyword. UNION Clause ‘The UNION clause is used to combine results that LECT appear from multiple SELECT statements and fier duplicates. For example, given a first_names table with a column name containing rows of data “James” and *Hermione*, L anda last_names table with a column name : containing rows of data “James”, “Hermione” and “Cassidy”, the result ofthis query would contsin three name s: “Cassidy”, “James”, and “Hermione”, hitpssiwww.codecademy.comearnlear-sqlimoduleslearn-sqhmultpletablesicheatsheet [codelcademy 18 1828724, 10:38 PM. [code]cademy Ross 301N Clause The CROSS JOIN clauses used to combine each row SELECT {rom one table with each row from another inthe result set. This JOIN is helpful for creating all possible ‘combinations forthe records (rows in two tables. ‘The given query will select the shirt_color and ppants_color columns from the result set which will contain all combinstions of combining the rows in the shirts and pants tables. there are 3 afferent shirt colors in the shirts table and 5 different pants colors in the pants table then the result set will contain 8x5 = 15 rows. Foreign Key ‘foreign key sa reference in one table's records to the primary key of another table. To maintain multiple records for a specific row, the use of foreign key plays a vital role. For instance, to track all the orders ofa specific Caren customer, the table order (ilustrated atthe bottom of Paul the image) can contain foreign key. Joseph ntps:hwww-codecademy convleamearn-sqiadulesiearn-sql-multple-ablesicheatsheet 28 1828724, 10:38 PM. Primary Key A primary key column in a SQL table is used to uniquely identify each record in that table. A primary key cannot be NULL. inthe example, customer_id isthe primary key, The same value cannot re-occur in a primary key 2 Ene ‘column. Primary keys are often used in JOIN 2 Aaron operations. 3 Tas Inner Join ‘The JOIN clause allows forthe return of results from more than one table by joining them together with other results based on common column values specified using an ON clause. INNER JOIN isthe default JOIN and it will only return results matching the condition specified by ON cb Print 8 Share v ntps:hwww-codecademy convleamearn-sqiadulesiearn-sql-multple-ablesicheatsheet 38.

You might also like