1 function of as
As can fill in the new table with the query result of select
CREATE TABLE profession
(id int (one) NOT NULL Auto_increment primary key,
profession varchar) as
sel ECT profession from the My_contacts group by the profession order by
profession;
alias for 2 columns
The column name changes the column name in the query result, but does not change the name of the source column. Aliases are only temporary. 3 alias of the table
Same as the alias of the column, as can omit
Select Profession (AS) mc_prof from
my_contacts (AS) MC
Group BY profession Order by
profession;
4 Mating
1 Cross joins
Cross joins (cross join), also called Cartesian product, cross product, return the result of each row of two tables
Select T.toy,b.boy from
toys as T
Cross join
boys as B;
/*cross join can be omitted */
2 Inner joins
Cross joins are one of the inner joins. An inner join is a cross connection that removes some result data rows from a condition in the query.
Select Somecolumns from
table1
inner join
table2 on
somecondition;
/*on can be changed to where*/
According to the different conditions, they can be divided into equal joins, unequal joins and natural joins.
/* Equal join *
/select T.toy,b.boy from
toys as T
inner join
boys as B on
b.toy_id=t.toy_id;
The conditions for unequal joins are "<>"
A natural join is an inner join that does not use the "on" clause. It is only useful if the joined columns have the same names in both tables.
Select T.toy,b.boy from
toys as T
Natural join
boys as B;