当前位置: 代码迷 >> 综合 >> 数据库中出现错误:1054 - Unknown column 'bus_car.car_id' in 'on clause'
  详细解决方案

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

热度:70   发布时间:2024-01-26 23:43:34.0

原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
  相关解决方案