我试图将delete语句重写为select语句,但是我一直遇到错误。这是我尝试重写的delete语句:

DELETE row1 FROM tableName row1, tableName row2 WHERE (row1.id > row2.id) AND (row1.col1 = row2.col1) AND (row1.col2 = row2.col2)


这是我尝试编写的select语句:

SELECT row1 FROM tableName row1, tableName row2 WHERE (row1.id > row2.id) AND (row1.col1 = row2.col1) AND (row1.col2 = row2.col2)


^ ---是的,这是完全错误的,但是我不确定如何解决。

最佳答案

使用'*'指定应选择所有列,例如

SELECT * FROM tableName row1, tableName row2
  WHERE (row1.id > row2.id) AND (row1.col1 = row2.col1) AND (row1.col2 = row2.col2)

关于php - 将DELETE语句重写为MYSQL中的SELECT语句,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34078877/

10-09 04:26