MySql查询错误,返回空集

时间:2014-02-13 12:25:51

标签: php mysql sql

我的数据库中有四个表

oc_paypal_cod_order
oc_paypal_cod_order_transaction

oc_paypal_order
oc_paypal_order_transaction

每个表都有一行。 我的第一个查询给了我一行

SELECT `ot`.*, 
    (SELECT count(`ot2`.`paypal_order_id`) 
       FROM `oc_paypal_order_transaction` `ot2` 
       WHERE `ot2`.`parent_transaction_id` = `ot`.`transaction_id` ) AS `children`
FROM `oc_paypal_order_transaction` `ot`
WHERE `paypal_order_id` = '1'

但我的第二个查询返回空集,而它应返回1行。

SELECT `ot`.*, 
    (SELECT count(`ot2`.`paypal_cod_order_id`) 
       FROM `oc_paypal_cod_order_transaction` `ot2` 
       WHERE `ot2`.`parent_transaction_id` = `ot`.`transaction_id` ) AS `children`
FROM `oc_paypal_cod_order_transaction` `ot`
WHERE `paypal_cod_order_id` = '2'

任何人都可以帮助我吗?

0 个答案:

没有答案