MySQL错误#1054字段中的未知列

时间:2016-08-05 06:39:18

标签: php mysql sql codeigniter

这是我的疑问:

SELECT COUNT( DISTINCT (paypal_transaction.buyerId) ) AS cid FROM eg_posts_details
INNER JOIN paypal_transaction ON paypal_transaction.id =  eg_posts_details.OrderId
WHERE seller_id =190

它直接在MySQL上运行完美但是当我从我的PHP codeigniter模型运行它时,我得到#1054错误。我不知道为什么会这样。请帮忙。

这是PHP代码:

 $query = $this->db->query("SELECT COUNT( DISTINCT (paypal_transaction.buyerId) ) AS cid 
FROM eg_posts_details 
INNER JOIN paypal_transaction ON paypal_transaction.id =  eg_posts_details.OrderId 
WHERE seller_id =190");

1 个答案:

答案 0 :(得分:1)

根据您的图片参考,paypal交易表包含buyerId,您将其用作buyer_id。所以使用以下内容。 像这样使用

$sql = "select count(distinct(`paypal_transaction`.`buyerId`)) as `cid` from `eg_posts_details` inner join `paypal_transaction` on `paypal_transaction`.`id` = `eg_posts_details`.`OrderId` where `seller_id`= '190' ";
$query = $this->db->query($sql);

希望它为你工作