An SQL associated query problem. Solution-php Tutorial

Source: Internet
Author: User
An SQL associated query problem. SQL mysql Association query

There are currently three tables

1: PRO table


2: ATTR table



3: ATTR2pro table



Check all products whose inner ring is 15 outer ring and whose keyword is gear first

How can I write a single SQL statement?

I need to learn more about SQL. Please advise ..

Note: MYSQL


Reply to discussion (solution)

Select * from PRO, (select * from ATTR2pro where attr_id = 1 and value = 15) t1, (select * from ATTR2pro where attr_id = 2 and value = 20) t2 where PRO. pro_id = t1.pro _ id and PRO. pro_id = t2.pro _ id

Upstairs. Thanks

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.