I got an error like this "Additional information: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near " when i running my code.Iam using webapi
string query = "SELECT `theatredetails`.*,`location`.`LocationName,`moviemaster`.`MovieMasterId`,`moviemaster`.`MovieName`,`moviemaster`.`Image` FROM `theatredetails` INNER JOIN `location` ON `theatredetails`.`LocationId`=`location`.`LocationId` INNER JOIN `moviemaster` ON `moviemaster`.`TheatreDetailsId`=`theatredetails`.`TheatreDetailsId`";
Iam using 3 inner joins,is there any error on my query?
You forgot a backtick
`location`.`LocationName
^---here
Related
When I execute this query
SELECT
*
FROM
user
INNER JOIN friend
ON user.user_id = friend.friend_id
WHERE friend.user_id = :userId
ORDER BY user.firstName ASC
I get this error:
Error Code: 1064. You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near ':userId ORDER BY user.firstName ASC' at line 7
I think you are trying PHP's PDO query directly in mysql, but mysql couldn't get it, Try to replace :userId by actual value you want to compare,
I just wanted to switch from sqlite3 to using MySQL but I get errors in this query:
SELECT
metapp_notif.id,
name,
age,
place,
note,
metapp_notif.lat,
metapp_notif.longt,
haslatlong,
dati,
ntype,
grpm_id,
image,
send_id,
pro.latitude,
pro.longtitude,
metapp_notif.dati,
metapp_notif.activity
FROM (metapp_notif
join (metapp_profil
join metapp_userlocation
ON metapp_profil.user_id = metapp_userlocation.user_id) AS pro
ON metapp_notif.send_id = pro.user_id)
WHERE metapp_notif.rec_id =% d;
I'm getting this error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'pro on metapp_notif.send_id=pro.user_id) where
metapp_notif.rec_id=2' at line 1
I was searching for differences between sqlite3 and mysql but can't figure out what is wrong.
Thanks in advance!
Try this syntax in Mysql
SELECT metapp_notif.id,
name,
age,
place,
note,
metapp_notif.lat,
metapp_notif.longt,
haslatlong,
dati,
ntype,
grpm_id,
image,
send_id,
latitude,
longtitude,
metapp_notif.dati,
metapp_notif.activity
FROM metapp_profil
join metapp_notif
ON metapp_notif.send_id = metapp_profil.user_id
join metapp_userlocation
ON metapp_profil.user_id = metapp_userlocation.user_id
WHERE metapp_notif.rec_id like '% d'; -- Not sure what you are trying to do here
MySQL query
select s.site_id,s.site_name,u.username
FROM cloud_search.dbo.site_request s join user_db.dbo.user_info u
on u.user_id=s.site_id;
Error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.site_request s join user_db.dbo.user_info u on u.user_id=s.site_id' at line 1
What am i doing wrong here..?
Are you sure you're using dbo it's usually for MSSQL
It's probably
select s.site_id,s.site_name,u.username FROM cloud_search.site_request s join user_db.user_info u on u.user_id=s.site_id;
SELECT core_student.STUDENT_ID, core_student.FIRST_NAME, core_student.LAST_NAME
FROM `core_student`
INNER_JOIN `ssp_student`
WHERE ssp_student.STUDENT_ID = core_student.STUDENT_ID;
throws an error on the WHERE clause:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to user near 'ssp_student' WHERE ssp_student.STUDENT_ID = core_student.STUDENT_ID
I just want to select the fields listed in the SELECT, then join all columns from ssp_student where the ssp_student.STUDENT_ID field is the same as the core_student.STUDENT_ID field.
Correct way is
SELECT core_student.STUDENT_ID, core_student.FIRST_NAME, core_student.LAST_NAME
FROM `core_student`
INNER JOIN `ssp_student`
on ssp_student.STUDENT_ID = core_student.STUDENT_ID;
Why do I always get a syntax error on the following inner join:
SELECT 'myapp_instagram_shop'.id
FROM 'myapp_instagram_shop'
INNER JOIN 'myapp_instagram_shop_picture'
ON 'myapp_instagram_shop'.id = 'myapp_instagram_shop_picture'.shop_id;
Error is:
1064 - You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near ''myapp_instagram_shop'
INNER JOIN 'myapp_instagram_shop_picture' ON 'sh' at line 1
try
SELECT myapp_instagram_shop.id FROM myapp_instagram_shop INNER JOIN myapp_instagram_shop_picture ON myapp_instagram_shop.id = myapp_instagram_shop_picture.shop_id;