user3844586
user3844586

Reputation: 151

How to Fix Error In SQL Query

Error SQL query: Documentation

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

Upvotes: 1

Views: 903

Answers (1)

Giorgos Betsos
Giorgos Betsos

Reputation: 72225

You are mixing implicit with explicit join syntax. Try this instead:

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

Note: Usage of LIMIT without an ORDER BY clause results in an arbitrary selection of records as there is no inherent order in an SQL table.

Upvotes: 5

Related Questions