Alternative to Intersect in MySQL

前端 未结 8 1715
暖寄归人
暖寄归人 2020-11-22 11:53

I need to implement the following query in MySQL.

(select * from emovis_reporting where (id=3 and cut_name= \'全プロセス\' and cut_name=\'恐慌\') ) 
intersect
( sel         


        
8条回答
  •  旧时难觅i
    2020-11-22 12:06

    Break your problem in 2 statements: firstly, you want to select all if

    (id=3 and cut_name= '全プロセス' and cut_name='恐慌')
    

    is true . Secondly, you want to select all if

    (id=3) and ( cut_name='全プロセス' or cut_name='恐慌')
    

    is true. So, we will join both by OR because we want to select all if anyone of them is true.

    select * from emovis_reporting
        where (id=3 and cut_name= '全プロセス' and cut_name='恐慌') OR
            ( (id=3) and ( cut_name='全プロセス' or cut_name='恐慌') )
    

提交回复
热议问题