这是我用来连接两个表的查询
SELECT `rf_popup`.*
FROM `rf_popup` LEFT JOIN
`g_metadata` ON (`rf_popup`.`name` = `g_metadata`.`name`)
WHERE (`g_metadata`.`g_id` = '2009112305475443' AND
`g_metadata`.`value` < rf_popup.cardinality OR
`g_metadata`.`g_id` IS NULL) AND
`category` IN ('S', 'all') AND
`field` IN ('descr', 'all') AND
`filler_type` IN ('F2', 'all')
ORDER BY `rf_popup`.`priority` DESC LIMIT 5
这是表 rf_popup
+--------------+------------------------------------------------------------------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+------------------------------------------------------------------------------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(200) | YES | | NULL | |
| text | text | YES | | NULL | |
| cardinality | int(11) | NO | | 1 | |
| field | varchar(200) | YES | | NULL | |
| category | enum('A','H','N','R','S','D','all') | YES | | NULL | |
| time_to_show | enum('START','END') | YES | | START | |
| filler_type | enum('F1','F2','F3','R1','R2','R3','all') | YES | | FILLER1 | |
| priority | int(11) | NO | | 0 | |
+--------------+------------------------------------------------------------------------
------------+------+------+---------+-------------- --+
这是表 g_metadata
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| g_id | varchar(50) | YES | MUL | NULL | |
| name | varchar(50) | YES | MUL | NULL | |
| value | varchar(200) | YES | | NULL | |
| id | int(11) | NO | PRI | NULL | auto_increment |
+-------+--------------+------+-----+---------+----------------+
但是查询返回空结果。但是如果我WHERE
在查询中替换为AND
. 查询返回结果。有什么区别??应该没有什么区别所以我很困惑