MySQL inner join, leftist, right join

Source: Internet
Author: User

--INNER JOIN----SelectGoods_id,goods_name,cate_name fromTdb_goodsInner JoinTdb_goods_cates ontdb_goods.cate_id=tdb_goods_cates.cate_id\g; The inner join returns both tables .SelectGoods_id,goods_name,brand_name fromTdb_goodsInner JoinTdb_brand ontdb_goods.brand_id=tdb_brand.brand_id;--left connection--SelectGoods_id,goods_name,cate_name fromTdb_goods Left JoinTdb_goods_cates ontdb_goods.cate_id=Tdb_goods_cates.cate_id\g The LEFT join returns the first (that is, the left) table .SelectGoods_id,goods_name,brand_name fromTdb_goods Left JoinTdb_brand ontdb_goods.brand_id=tdb_brand.brand_id; Values that are not referenced by the right table are replaced with null--Right Connection--SelectGoods_id,goods_name,cate_name fromTdb_goods Right JoinTdb_goods_cates ontdb_goods.cate_id=tdb_goods_cates.cate_id\g; The right Join returns a second (that is, the right) table .SelectGoods_id,goods_name,brand_name fromTdb_goods Right JoinTdb_brand ontdb_goods.brand_id=tdb_brand.brand_id; Values that are not referenced by the left table are replaced by null instead of the control:SelectGoods_id,goods_name,brand_name fromTdb_brand Left JoinTdb_goods ontdb_goods.brand_id=tdb_brand.brand_id; Summary: The INNER join will only show the columns in both tables, left connection reference left table, the right table has no value to set NULL, right connection reference right table, left table no value is set NULL, the table name is the same as the connection between the two tables. 

MySQL inner join, leftist, right join

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.