問題是我有DATA和SAT表有3個字段,這些字段中的每一個都可能包含值991.下面的列不給出正確數量的列給出更多數據。如何獲得正確的價值。請指點MYSQL查詢返回更多的值
DATA
id
insurance1
insurance2
insurance3
SAT
id
insurance1
insurance2
insurance3
SELECT * FROM DATA v, SAT s where v.PRIMARY_INSURANCE_ID = '991'
or v.INSURANCE_ID = '991'
or v.INSURANCE_ID = '991'
and s.INSURANCE_ID = '991'
or s.INSURANCE_ID = '991'
or s.INSURANCE_ID = '991';
讓我舉一個例子 例1
DATA
id
insurance1 =991
insurance2 =56
insurance3 =22
SAT
id
insurance1=56
insurance2=23
insurance3=96
When query is executed. The count should be 1
例2
DATA
id
insurance1 =991
insurance2 =56
insurance3 =22
SAT
id
insurance1=991
insurance2=23
insurance3=96
When query is executed. The count should be 2
例3
DATA
id
insurance1 =991
insurance2 =56
insurance3 =991
SAT
id
insurance1=991
insurance2=23
insurance3=96
When query is executed. The count should be 3 or 2
DATA ID insurance1 = 991 insurance2 = 56 insurance3 = 36 – CodingPerson 2014-10-20 12:21:36