MySQL许多'和'语句(MySQL many 'and' statements)
我有这个说法,这是错误的方法,但我怎么能让语句工作(语句的结果需要保存所有的AND)
SELECT a.username, a.first_name, a.last_name , b.tx_time, b.account_id , a.id , b.table_id, b.tx_type, b.amount FROM punter a , account_transaction b WHERE b.tx_time >= '2011-07-01' AND b.tx_time < '2011-09-30' AND b.account_id = a.id AND b.tx_type = 4 AND b.tx_type = 14I have this statement wich is the wrong way to do it but how would I get the statement to work (the result of the statement needs to hold all the AND in it)
SELECT a.username, a.first_name, a.last_name , b.tx_time, b.account_id , a.id , b.table_id, b.tx_type, b.amount FROM punter a , account_transaction b WHERE b.tx_time >= '2011-07-01' AND b.tx_time < '2011-09-30' AND b.account_id = a.id AND b.tx_type = 4 AND b.tx_type = 14最满意答案
AND b.tx_type = 4 AND b.tx_type = 14将为您提供空结果集。 一列只能同时拥有一个值。
SELECT a.username, a.first_name, a.last_name, b.tx_time, b.account_id, a.id, b.table_id, b.tx_type, b.amount FROM punter a INNER JOIN account_transaction b ON b.account_id = a.id WHERE b.tx_time BETWEEN '2011-07-01' AND '2011-09-30' AND b.tx_type IN (4,14)AND b.tx_type = 4 AND b.tx_type = 14 will give you empty result set. One column can only have one value at the same time.
SELECT a.username, a.first_name, a.last_name, b.tx_time, b.account_id, a.id, b.table_id, b.tx_type, b.amount FROM punter a INNER JOIN account_transaction b ON b.account_id = a.id WHERE b.tx_time BETWEEN '2011-07-01' AND '2011-09-30' AND b.tx_type IN (4,14)更多推荐
发布评论