Usage of LEFT OUT JOIN

xiaoxiao2021-03-06  63

Table1 and Table2 are equipped with the following: Select A.ID, A.Name, A.housenumber, B.housenumber, B.houseName from table1 a, table2 b where a.housenumber = b.housenumber a.housenumber with B.houseNumber They are foreign keys and primary keys, if a.housenumber has a space value, when you want to select all columns of Table1, the equivalent connection makes data loss. For example:

Multiple device records in the device table A, connected to the vendor record of the B table, we want to list all the devices, should choose A left external connection B, display all of the rows in A and connect to B Supplier information. A SQL statement of the table to the top of the table B table: select a.id, a.name, b.supply from table1 a left outer join table2 b on a.supply_id = b.supply_id a table left outer connection B, C, D, E and other tables and SQL statements output by selecting conditions: select a.machine_id, a.pro_num, a.machine_name, a.machine_type, b.brand_name, a.Unitprice, a.sn, a.service_num, c.supply_name, D.ROOM_NAME, A.INSTALL_PLACE, A.INSTALL_MAN, E.State_name, a.buydate, f.Project_name, a.Memo from machine a left outer join brand b on (a.brand_id = B.BRAND_ID) Left Outer Join Supply C On (a.supply_id = C.supply_ID) Left Outer Join Room D on (a.ROOM_ID = D.ROOM_ID) Left Outer Join State E ON (A.State = E.State_ID) Left Outer Join Project f on (A.Project_ID = F.Project_id) Where (a.machine_id = 7) More Content Connection: http://www900.ibm.com/developerWorks/cn/dmdd/tevell/techarticles/0112purcell/0112purcell.shtml#leftoj http: // www900 .ibm.com / developerWorks / CN / DMDD / LIBRARY / TECHARTICLES / 0201PURCELL / 0201PURCELL.SHTML specifically outlined

转载请注明原文地址:https://www.9cbs.com/read-119231.html

New Post(0)