Mysql连接条件连接同一服务器中的两个数据库

时间:2015-12-03 18:10:28

标签: mysql mysql-workbench

select first_name, last_name, amount, payment_date 
from customer_db.customer_data c
join employee_db.payment e
on c.customer_id= e.payment_id 
where customer_db.customer_data(customer_id)='6';

我正在

12:05:54    select first_name, last_name, amount, payment_date  from customer_db.customer_data c join employee_db.payment e on c.customer_id= e.payment_id  where customer_db.customer_data(customer_id)='6' LIMIT 0, 1000
Error Code: 1305. FUNCTION customer_db.customer_data does not exist 0.000 sec

3 个答案:

答案 0 :(得分:0)

你试图调用一个函数:

where customer_db.customer_data(customer_id)='6';
                               ^-----------^

也许你的意思是

where customer_db.customer_data.customer_id='6';
                               ^---

代替?

答案 1 :(得分:0)

您在查询中使用表的别名,因此您必须将其替换为:

customer_db.customer_data.customer_id

使用

c.customer_id

答案 2 :(得分:0)

select customer_db.customer_data.first_name, customer_db.customer_data.last_name, employee_db.payment.amount, employee_db.payment.payment_date 
from customer_db.customer_data
inner join employee_db.payment
on customer_db.customer_data.customer_data_id = employee_db.payment.payment_id
where customer_db.customer_data.customer_data_id ='6'; 

我终于找到了解决方案。 Thannks