将DELETE语句重写为MYSQL中的SELECT语句

时间:2015-12-04 00:30:30

标签: php mysql database select mysqli

我试图将一个删除语句重写为一个select语句,但我不断收到错误。这是我试图重写的删除语句:

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)

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

1 个答案:

答案 0 :(得分:1)

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

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