php - 如何修复 SQL 查询中的错误

标签 php mysql sql

错误 SQL 查询:文档

SELECT * 
FROM tbl_vehicle_details 
INNER JOIN tbl_user, tbl_ride 
ON `tbl_vehicle_details`.`v_u_id` = `tbl_user`.`u_id` AND 
   `tbl_ride`.`r_v_id` =`tbl_vehicle_details`.`v_id` 
LIMIT 0, 25

MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ON tbl_vehicle_details.v_u_id = tbl_user.u_id AND tbl_ride.r_v_id = ' at line 1

最佳答案

您将隐式连接语法与显式连接语法混合在一起。试试这个:

SELECT * 
FROM tbl_vehicle_details 
INNER JOIN tbl_user
ON `tbl_vehicle_details`.`v_u_id` = `tbl_user`.`u_id`
INNER JOIN tbl_ride 
ON `tbl_ride`.`r_v_id` =`tbl_vehicle_details`.`v_id` 
LIMIT 0, 25

注意:在没有 ORDER BY 子句的情况下使用 LIMIT 会导致任意选择记录,因为 SQL 中没有固有顺序表。

关于php - 如何修复 SQL 查询中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36028059/

相关文章:

php - 使用触发器来防止在 MySQL 中插入代码

sql - 在 SSIS 中将字符串转换为 DateTime

php - 如何找出 View 中特定字段的总和 Codeigniter

php - cron centOS "Could not open input file"错误

php - 从YouTube API JSON响应(PHP)中随机选择一个视频

mysql - MySQL 是否应该将其时区设置为 UTC?

mysql - RDS over MySQL 出现奇怪的延迟

sql - 在子查询中分组?

sql - MSSQL : single quotes causes to error in queries

php - 拉维尔 4 : Prevent form re-submissions