doq1969 2013-06-10 01:52
浏览 23
已采纳

试图为用户显示@mentions但我的查询正在吐出错误

I'm trying to display @mentions for my currently logged in user but I'm getting a syntax error and I don't know what it is. My database is mysql and my query currently looks like this:

$sql = "SELECT 
    users.username,
    posts.post,
    posts.time_stamp,
FROM users
INNER JOIN posts 
ON users.id = posts.user_id
INNER JOIN mentions
ON users.id = mentions.user_id
WHERE mentions.user_id = '$userid'
AND mentions.unread = 1
ORDER BY time_stamp DESC
"; 

What I want to happen is for the currently logged in user to go to a page called "mentions" and to get a list of the posts they were mentioned in and the username who mentioned them BUT ONLY if the mention is unread (i.e. is equal to 1) because later on that same page I will then change the displayed mentions 'unread' status to 0, which means it has been read.

I hope this makes sense! If you need more info on the db structure etc, shoot a comment and I will give you more info.

  • 写回答

1条回答 默认 最新

  • dongtuan1594 2013-06-10 01:55
    关注

    You have at least one syntax error in this line:

    posts.time_stamp,
    

    Remove the comma. It is not needed before from.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集