PHP中使用多个条件的Mysql删除查询
我想从表(PHP + Mysql)中删除数据,有三个条件。我尝试了“AND”和“,”,但不起作用。
mysql_query("DELETE FROM `posts-meta` WHERE `post_id` = '$postid' AND `meta_name` = 'post_tag' AND `meta_value` = '$tag'")
有什么办法吗?
I want to delete data from table (PHP + Mysql), with three conditions. I tried both 'AND' and ',' but don't work.
mysql_query("DELETE FROM `posts-meta` WHERE `post_id` = '$postid' AND `meta_name` = 'post_tag' AND `meta_value` = '$tag'")
Is there any way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您正在寻找一个查询,该查询将删除与所有三个条件匹配的结果,那么您的查询是准确的:
如果您要删除与任一条件匹配的所有结果,您应该去与 OR:
希望我不会通过用这些常识重新陈述明显的内容来冒犯您,尽管您的问题确实缺少上下文,但我不知道您到底想要完成什么,为什么它不起作用,。 ..
If you're looking for a query that'll delete the results that match to all three of your conditions, you're query is accurate:
If you're looking to delete all results matching to either one of your conditions, you should go with OR:
Hope I don't offend you by re-stating the obvious with this common knowledge, though your question is really missing context, I have no idea what exactly you're trying to accomplish, why it doesn't work, ...
不要用这种丑陋的方式运行查询,而是将所有代码塞进一行,始终使其合理,并始终添加一些错误检查。
如果您有以这种方式运行查询的习惯,至少
您会收到有关错误的通知,并且不会浪费您和其他人的时间。
instead of this ugly way of running queries, stuffing all your code in just one line, always make it sensible, and always add some error checking.
If you had a habit of running queries at least this way
you'd been notified of the error and wasted no time of yours and other people.