【问题标题】:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL#1064 - 您的 SQL 语法有错误;检查与您的 MySQL 对应的手册
【发布时间】:2014-04-15 15:25:36
【问题描述】:
#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

【问题讨论】:

  • 您是否要减去表格? ;-P uporabnik-sporocilo
  • 它是表的名称。

标签: mysql sql select phpmyadmin


【解决方案1】:

如果您的列标识符将包含破折号,您必须将它们包装在刻度中。否则 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;

【讨论】:

  • @user2603949 另外,作为旁注,请开始使用显式连接,不推荐使用隐式连接。您还应该知道,您使用的 LIKEs 基本上是和 = 运算符,因为您没有使用任何通配符 ('%')
【解决方案2】:

语法错误是缺少引号,这里:

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

在该行末尾加上逗号。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-14
    • 2017-06-30
    • 2013-07-25
    • 1970-01-01
    • 1970-01-01
    • 2019-11-22
    相关资源
    最近更新 更多