mysql - 减去两个基于 2 列的表

标签 mysql

I need to SELECT the rows of 'billing_temp' that doesn't exist in 'billing' based on two columns.

目前我想出了这个查询:

SELECT ControlNum, CarrierName, PhoneNum, PatientName, SubscriberID, SubscriberName, 
ChartNum, DoB, SubscriberEmp, VisitID, ServiceDate, ProviderName, CPTCode, BillingDate, 
AgingDate, BalanceAmt, Age, AgeCategory FROM billing_temp LEFT JOIN billing 
USING (ControlNum, CPTCode) WHERE billing.ControlNum=billing_temp.ControlNum AND 
billing.CPTCode=billing_temp.CPTCode

但是我得到了错误:

Column 'ControlNum' in fieldlist is ambiguous.

有没有人遇到过这种情况。

如果您需要更多详细信息来恢复此信息,请通知我.. 帮我。提前致谢..

注意:

很抱歉,我在自己的查询中发现了问题所在。 感谢所有对我的问题感兴趣并发送答案的人..

最佳答案

在多个表中存在的字段名称(在您的查询中)的每次出现都必须是完全限定的。在您的情况下,billing.ControlNumbilling_temp.ControlNum

关于mysql - 减去两个基于 2 列的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3468184/

相关文章:

mysql - 构建大型PHP+MySQL项目

c# - 拼字游戏查找器 : building a trie, 存储一个 trie,使用一个 trie?

php - 获取每个用户的最新 N 个帖子

php - 将 $_GET 传递给 mySQL 查询

mysql 存储过程返回 0 行受影响

mysql 在 JOIN 上返回重复项

php - 在 php 中使用 pdo 创建数据库

php - 将mysql数据转换成人类可读的格式

php - Laravel 4 分页按钮不起作用(查询整个数据库)

php - Wordpress 插入查询运行 3 次