数据库
首页 > 数据库> > 数据库中出现错误:1054 - Unknown column 'bus_car.car_id' in 'on clause'

数据库中出现错误:1054 - Unknown column 'bus_car.car_id' in 'on clause'

作者:互联网

原sql为:

SELECT
bus_car.car_id,
bus_car.car_name,
bus_customer.customer_id,
bus_customer.cust_name,
bus_rent.rent_id,
bus_rent.begin_date,
bus_rent.end_date,
bus_rent.price,
bus_rent.rent_flag,
bus_rent.oper_name,
bus_rent.rent_time,
bus_rent.rent_remark,
bus_customer.phone,
bus_customer.identity,
bus_customer.sex,
bus_customer.driver_license,
bus_car.car_color
FROM
bus_car ,
bus_customer
INNER JOIN bus_rent ON bus_rent.car_id = bus_car.car_id AND bus_rent.customer_id = bus_customer.customer_id

给from后的两个表加上括号即可

SELECT
bus_car.car_id,
bus_car.car_name,
bus_customer.customer_id,
bus_customer.cust_name,
bus_rent.rent_id,
bus_rent.begin_date,
bus_rent.end_date,
bus_rent.price,
bus_rent.rent_flag,
bus_rent.oper_name,
bus_rent.rent_time,
bus_rent.rent_remark,
bus_customer.phone,
bus_customer.identity,
bus_customer.sex,
bus_customer.driver_license,
bus_car.car_color
FROM
(bus_car ,
bus_customer)
INNER JOIN bus_rent ON bus_rent.car_id = bus_car.car_id AND bus_rent.customer_id = bus_customer.customer_id
对,是我 发布了55 篇原创文章 · 获赞 14 · 访问量 6195 私信 关注

标签:customer,1054,name,column,car,rent,bus,id
来源: https://blog.csdn.net/qq_41154522/article/details/104614960