Record memo, initial data is as follows:
DROP TABLE IF EXISTSt_demo_product;CREATE TABLE IF not EXISTSt_demo_product (proidint( -), Pronamevarchar( -), priceint(Ten), PRIMARY KEY(proid)) ENGINE=InnoDBDEFAULTCHARSET=GBK;DROP TABLE IF EXISTSt_demo_operation;CREATE TABLE IF not EXISTSt_demo_operation (Opidint(Ten), Proidint( -), Opcountint(Ten), PRIMARY KEY(Opid)) ENGINE=InnoDBDEFAULTCHARSET=GBK;Insert intoT_demo_product (proid, Proname, Price)Values(1,'Product A','Ten'),(2,'Product B',' One'),(3,'Product C',' A'),(4,'Product D',' -'),(5,'Product e',' -');Insert intoT_demo_operation (Opid, proid, Opcount)Values(1,1,2),(2,3,6),(3,3,1),(4,4,3),(5,7,3);
Internal connection, does not allow empty
SELECT * from T_demo_product A, t_demo_operation b where a.proid = b.proid;
SELECT * from T_demo_product a joins t_demo_operation b on a.proid = b.proid;
Left JOIN, to T_demo_product-based, if the corresponding existence of multiple records are recorded more than one, none is empty
SELECT * FROM T_demo_product a LEFT join t_demo_operation b on a.proid = b.proid;
Right connection, to t_demo_operation-based, if the corresponding to more than one record, no is empty
SELECT * from T_demo_product a right joins t_demo_operation b on a.proid = b.proid;
MySQL internal connection, left join, right connection