1. Join has left Join,right Join,inner join these three kinds, two tables do a Cartesian product, and then select the result set, select the part that satisfies the condition as the result.
- Join (INNER JOIN): Returns a row if there is at least one match in the table (Note: INNER join is the same as join.) )
- Left JOIN (outer join:): Returns all rows from the left table, even if there is no match in the right table (note: In some databases, the Ieft join is called the OUTER join. )
- Right join: Returns all rows from the right table, even if there are no matches in the left table (note: In some databases, the correct join is called a OUTER join. )
- Full join (all outer joins): Returns a row whenever a match exists in one of the tables (note: In some databases, the complete join is called the full OUTER join. )
2.in is used as a conditional query:
SELECT * from Persons where lastName in (' Adams ', ' Carter ')
Two statements, you can use the SQL optimizer to see how efficiently they perform:
Select COUNT (Distinct (typ.orig_id)) from Sch. Nwstyp Typ left outer join Sch. Nwsatt att on typ.orig_id = att. orig_id where Att.fld_code = ' 4 ' and att.fld_val = ' 1101 ';
Select COUNT (Distinct (typ.orig_id)) from Sch. Nwstyp Typ,sch. Nwsatt att where typ. Typ_code = ' 1501 ' and typ.orig_id = att. orig_id and Att.fld_code = ' 4 ' and att.fld_val = ' 1101 ';
The second SQL above is used by default with the inner join.
The online search also mentions exist.
Found an article:
Http://weblogs.sqlteam.com/mladenp/archive/2007/05/18/60210.aspx
Can see.
The difference between join in SQL and the usage of join