我有专栏
First name | last name | nr (individual number) | pref1 (preference1) | pref2 (preference2)| pref3(preference3) | situation | distance | sex
一张表中有 100 条记录
在所有的结果中,我不能有裁员。这意味着当我在第一组结果中获得例如“2112”的单个编号(列“nr”)时,它不能显示在最后一个结果中。
SELECT DISTINCT nr FROM ap
第一次查询的记录:
WHERE sex='F' and pref1='1' ORDER BY situation DESC, distance DESC
AND WHERE (sex='F' and pref2='1' and situation= ' ' ) ORDER BY distance DESC
and WHERE (sex='F' and pref3='1' and situation= ' ' ) ORDER BY distance DESC
LIMIT 4
然后我想加入第二个查询的结果:
WHERE sex='M' and pref1='2' ORDER BY situation DESC, distance DESC
AND WHERE (sex='M' and pref2='2' and situation= ' ' ) ORDER BY distance DESC
AND WHERE (sex='M' and pref3='2' and situation= ' ' ) ORDER BY distance DESC
LIMIT 7
然后加入上次查询的所有记录:
WHERE sex='F' and pref1='3' ORDER BY situation DESC, distance DESC
AND WHERE (sex='F' and pref2='3' and situation= ' ' ) ORDER BY distance DESC
AND WHERE (sex='F' and pref3='3' and situation= ' ' ) ORDER BY distance DESC
LIMIT 10
有可能吗?