gpt4 book ai didi

mysql - MySQL 未知列左连接

转载 作者:行者123 更新时间:2023-11-29 23:33:07 25 4
gpt4 key购买 nike

我使用了“NOT IN(选择)”功能,但加载多个寄存器需要很长时间。所以我想使用 LEFT JOIN 改进查询,但我不知道出了什么问题。我收到 #1054 - “on Clause”中的未知列“a.id_logistica”。表“logistica”中的“id_logistica”列确实存在,就像在“det_log”表中一样。这是代码:

SELECT 
a.*, a.id_logistica,
b.nombre username, c.placa,
b.nombre scliente, e.nombre ruta,
d.nombre_con, clase
FROM
logistica a, cliente b,
vehiculo c, conductores d, ruta e
LEFT OUTER JOIN
det_log t2 ON t2.id_logistica = a.id_logistica
WHERE
a.id_cliente = b.id_cliente AND a.id_ruta = e.id_ruta
AND t2.id_logistica IS NULL AND a.id_vehiculo = c.id_vehiculo
AND a.id_conductor = d.id_conductor AND activo = 1
and finalizado = 0 AND ( a.id_ruta > 1 OR a.borrado = 9 )
ORDER BY
fecha_des DESC

最佳答案

如果您的查询正在运行,您可以尝试这个:

SELECT 
a.*, a.id_logistica,
b.nombre username, c.placa,
b.nombre scliente, e.nombre ruta,
d.nombre_con, clase
FROM logistica a
Left Join cliente b On b.id_cliente = a.id_cliente
Left Join vehiculo c On c.id_vehiculo = a.id_vehiculo
Left Join conductores d On d.id_conductor = a.id_conductor
Left Join ruta e On e.id_ruta = a.id_ruta
Left Join det_log t2 On t2.id_logistica = a.id_logistica
WHERE ( a.id_ruta > 1 OR a.borrado = 9 )
And activo = 1
And finalizado = 0
And t2.id_logistica IS NULL
ORDER BY fecha_des DESC

但是,如果我查看错误。表“logistica”中的“id_logistica”列没有任何意义。

请检查表“logistica”中的列。

desc logistica;

也许,你写错了。

关于mysql - MySQL 未知列左连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26476751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com