160523SQL simple four kinds of query statements

Source: Internet
Author: User

--Find products with a product price greater than $15 and a purchase of more than 1 items at a time.
--1.
Select A.product_id,a.name from
(SELECT * FROM Products p where p.price>15) a INNER join
(SELECT * from purchases PR where pr.quantity>1) b on
a.product_id=b.product_id
--2.
Select P.product_id,p.name from Products p INNER JOIN purchases PR
On p.product_id=pr.product_id and p.price>15 and pr.quantity>1;
--3.
Select P.product_id,p.name from Products p where p.price>15 and p.product_id in
(select pr.product_id from purchases PR where pr.quantity>1);
--4.
Select p.product_id from Products p where p.price>15
Intersect
Select pr.product_id from purchases PR where pr.quantity>1

160523SQL simple four kinds of query statements

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.