mysql查询的意外行为

时间:2014-07-03 10:02:29

标签: mysql

考虑以下问题:

SELECT i.id  AS item_id, 
       i.name, 
       i.project_id, 
       iv.id AS variation_id, 
       iv.price 
FROM   items AS i 
JOIN items_variations AS iv ON iv.id = (
    SELECT ivv.id FROM items_variations AS ivv 
    JOIN items_pictures AS ip2 
        ON ip2.variation_id = ivv.id 
        AND (( ip2.thumb = 1 AND ip2.details = 1 AND ip2.visible = 1 AND ip2.format = 3 ) 
            OR ( ip2.cover = 1 AND ip2.details = 1 AND ip2.visible = 1 AND ip2.format = 3 ) ) 
        WHERE  ivv.item_id = i.id AND ivv.status = 1 
        ORDER  BY ivv.price ASC 
        LIMIT  1) 
WHERE  i.id = 60 

返回空集。如果我从select子句中删除字段iv.price,则返回一行。 我对这种行为感到非常惊讶,你对于为什么会发生这种情况有任何线索吗?

我目前正在使用mysql Ver 14.14 Distrib 5.5.28,for Linux(x86_64)使用readline 5.1

0 个答案:

没有答案