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.

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度