SQL, deduplicate query distinct solution

Source: Internet
Author: User
SQL, deduplicate query distinct & nbsp; select & nbsp; DISTINCT & nbsp; 'object _ id', & nbsp; t3.width & nbsp; as & nbsp; width, & nbsp; t3.height & nbsp; as & nbsp; height, t3.ismark & nbsp; as & nbsp; ismark, & nbsp; t2.rtime & nbs SQL, deduplicated query distinct

Select DISTINCT 'object _ id', t3.width as width, t3.height as height, t3.ismark as ismark, t2.rtime as add_time, t1.add _ author as add_author, t1.image _ url as image_url, t1.id as id, t1.browse _ real_cnt as browse_real_cnt
From comments as t2
Left join ornamentations as t1 on t1.id = t2.object _ id
Left join ornamentation_images as t3 on t3.ornamentation _ id = t1.id
Where (t2.uid = 1013) AND (t1.enable = '0 ')
Order by t2.id desc LIMIT 0, 5


The condition after select is normal with t3, which can be repeated. after t2 is added, t1 cannot be repeated.
------ Solution ----------------------
DISTINCT acts on the entire line
It's hard to say that your three tables only have one to multiple tables.

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.