简体   繁体   English

PHP MYSQL从WHERE AND子句删除

[英]PHP MYSQL DELETE FROM WHERE AND clause

Trying to get the following to work but for the life of me i cannot get this working. 试图让以下人员工作,但为了我的一生,我无法进行这项工作。

Could someone assist? 有人可以帮忙吗?

DELETE FROM 'content' WHERE note_id = '7' AND WHERE userid = '1'
DELETE FROM 'note' WHERE id = '7' AND WHERE userid = '1'

I need to delete a record from each table where it checks that the user is actually that user but im getting syntax error when I run the query 我需要从每个表中删除一条记录,在该表中它会检查该用户实际上是该用户,但是在运行查询时出现语法错误

I Receive the following when I remove the 2nd WHERE. 当我删除第二处时,会收到以下消息。

SQL Error (1064): You have an error in your SQL syntax; SQL错误(1064):您的SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntac to user near 'DELETE FROM note WHERE id ='7' AND userid = '1" at line 2 检查与MySQL服务器版本相对应的手册,以找到第2行“ DELETE FROM note WHERE id ='7'AND userid ='1”附近的用户的正确语法

Apologies turns out I added an extra space before the script got to here 抱歉,我在脚本到达此处之前添加了额外的空间

Only 1 WHERE needed, try this: 只有1 WHERE需要,试试这个:

DELETE FROM content WHERE note_id = '7' AND userid = '1'
DELETE FROM note WHERE id = '7' AND userid = '1'

You can't use single quotes around table names: 您不能在表名周围使用单引号:

DELETE FROM `content` WHERE note_id = '7' AND userid = '1'

You have to use backticks around table and column names - not single quotes. 您必须在表名和列名周围使用反引号-而不是单引号。

Also: You had two where in there - just use and between extra clauses. 另外:您在where有两个where -仅在额外的子句之间使用and

You've added multiple WHERE clauses in a single query, which will not work. 您在单个查询中添加了多个WHERE子句,该子句将不起作用。

Try this: 尝试这个:

DELETE FROM content WHERE note_id = '7' AND userid = '1'

DELETE FROM note WHERE id = '7' AND userid = '1'

Use 采用

DELETE FROM 'content' WHERE note_id = '7' AND userid = '1'
DELETE FROM 'note' WHERE id = '7' AND userid = '1'
 DELETE FROM content WHERE note_id = '7' AND userid = '1'
 DELETE FROM note WHERE id = '7' AND userid = '1'

Try this there were two errors, ' with table and where clause written twice 尝试这样做有两个错误,“与表和where子句两次写入”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM