Mysql 查询 except 和 where
我有以下查询从数据库中选择内容:
mysql_query("SELECT * FROM categories order by id desc EXCEPT
WHERE id = $post_id")
or die(mysql_error());
我想要做的是选择“category”表中的所有列,按 id 降序排列它们,除非列“id”等于变量 $post_id。
然而,这是行不通的。我对这类东西比较陌生,所以你们能给我指出正确的方向吗?我真的很感激。
谢谢!
I have the follow query selecting stuff from a database:
mysql_query("SELECT * FROM categories order by id desc EXCEPT
WHERE id = $post_id")
or die(mysql_error());
What I want to do is select all the columns in the "category" table, order them by id descending except where the column "id" equals the variable $post_id.
However, this does not work. I'm relatively new to this sort of stuff so could you guys give me a pointer in the right direction? I'd really appreciate it.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
try this instead: