这是我的疑问:
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");
答案 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);
希望它为你工作