#1064 - 您的SQL语法有错误;查看与MySQL对应的手册

时间:2014-04-15 15:25:37

标签: mysql sql select phpmyadmin

#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 '-sporocilo us, uporabnik u WHERE ( 's%' LIKE
u.uuser) AND (s.SID = us.SID) AND (' at line 2   

这是我得到的错误......

SQL:

SELECT us.ussender, s.ssubject, s.scontent, us.ustimesend, us.usstatus,
FROM sporocilo s, uporabnik-sporocilo us , uporabnik u
WHERE ($user LIKE u.uuser) AND (s.SID = us.SID) AND (us.usreciever LIKE u.uuser),
ORDER BY us.ustimesend ASC; 

数据库:http://my.jetscreenshot.com/20224/20140415-ls6n-41kb

2 个答案:

答案 0 :(得分:2)

如果您的列标识符将包含破折号,则必须将它们包含在刻度中。否则MySQL假定您正在执行减法操作。

SELECT us.ussender, s.ssubject, s.scontent, us.ustimesend, us.usstatus, 
FROM sporocilo s, `uporabnik-sporocilo` us , uporabnik u 
WHERE ($user LIKE u.uuser) AND (s.SID = us.SID) AND (us.usreciever LIKE u.uuser), 
ORDER BY us.ustimesend ASC;

答案 1 :(得分:0)

语法错误缺少引号,此处:

WHERE ($user LIKE u.uuser) AND (s.SID = us.SID) AND (us.usreciever LIKE u.uuser), 

加上该行末尾的逗号。

您的查询还有其他问题,但这超出了您的问题的范围。