Use of and or in mysql joint Query

Source: Internet
Author: User

Demand Environment:

Function: resume search

Requirement: You can select either full-time, part-time, temporary, or intern, but only one type of resume is required. You must list all your resumes that meet any of the requirements.

Obstacle: if any of the or conditions is TRUE, the judgment is stopped, and the and condition returns the intersection.

 

SELECT

T_person_info.personid,

T_person_info.personname,

T_person_info.sex,

T_person_edu.education,

T_person_edu.school,

T_person_edu. 'subobject ',

T_person_edu. 'to'

FROM

T_person_info

Left join t_person_edu ON t_person_edu.personid = t_person_info.personid

WHERE 1 = 1

 

AND (type = 3 OR type = 1)

AND (company = 222 OR company = 'hubei Index ')

When 14 and 15 rows are viewed, the conditions or conditions in the brackets are preferentially executed, and then the nearest condition on the left of the brackets is executed. This condition is applicable to the union of the same field.

This article is from the "golden pig's PHP growth path" blog

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.