然后我有以下查询:查询帮助 - Where子句
mysql_select_db($database_conndb1, $conndb1);
$query_rsName = sprintf("
SELECT DISTINCT
table1.search_id, table1.search1, table1.search2, table1.search3, table1.search4, table1.search5, table1.search6, table1.search7, table1.search8, table1.search9, table1.search10, table1.search11, table1.search12, table1.search13, table1.search14, table1.search15, table1.search16, table2.search_id
FROM table1, table2
WHERE
table2.criteria1 = %s OR
table2.criteria2 = %s OR
table2.criteria3 = %s OR
table2.criteria4 = %s OR
table2.criteria5 = %s OR
table2.criteria6 = %s OR
table2.criteria7 = %s OR
FIND_IN_SET(%s, table2.criteria8) OR
table2.criteria9 = %s OR
table2.criteria10 = %s OR
table2.criteria11 = %s AND
table1.search_id = table2.search_id
ORDER BY
table1.search2 DESC",
GetSQLValueString($search1_rsName, "text"),
GetSQLValueString($search2_rsName, "text"),
GetSQLValueString($search3_rsName, "text"),
GetSQLValueString($search4_rsName, "text"),
GetSQLValueString($search5_rsName, "text"),
GetSQLValueString($search6_rsName, "text"),
GetSQLValueString($search7_rsName, "text"),
GetSQLValueString($search8_rsName, "text"),
GetSQLValueString($search9_rsName, "text"),
GetSQLValueString($search10_rsName, "text"),
GetSQLValueString($search11_rsName, "text"));
然而,当查询是跑,它拉的所有记录,并做每个记录十次 - 不只是那些基于搜索条件。现在,如果我将OR更改为AND并选择全部11,则它应该可以正常工作。因此,它与OR操作数有关。但是,我无法弄清楚什么是错的。除OR以外,我还可以使用哪些操作数,以允许搜索者选择1,2,3或更多条件?
请格式化您的代码/查询。并请狐狸你的标题(使其描述)。 – PeeHaa
如果您看到由X返回的相同记录加入表中的行数,那么您将获得笛卡尔联接... – Trent