First name | last name | nr (individual number) | pref1 (preference1) | pref2 (preference2)| pref3(preference3) | situation | distance | sex
与100只记录在一个表中AP
在所有我不能有冗余的结果。这意味着当第一组结果中我得到前面的例子'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
是否有可能t做什么?
既然你展示SQL是无效的,这是很清楚你是什么后,只是一个简单的例子。你能不能展示一些示例表格行以及你的查询输出结果的样本? – 2012-07-07 12:01:57