简体   繁体   English

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

[英]MySQL error #1054 unknown column in field

This is my 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

It runs perfectly on MySQL directly but when I run it from my PHP codeigniter model I get the #1054 error. 它可以直接在MySQL上完美运行,但是当我从PHP codeigniter模型运行它时,出现#1054错误。 I have no idea why this is happening. 我不知道为什么会这样。 Please help. 请帮忙。

Here is the PHP code: 这是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");

As per your image reference, paypal transaction table contain buyerId and you used it as buyer_id. 根据您的图片参考,贝宝(Paypal)交易表包含BuyerId,并将其用作Buyer_id。 So use the following. 因此,请使用以下内容。 Use like this 这样使用

$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);

Hope its work for you 希望它对你有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM