SQL Delete clears the table instead of erroring

后端 未结 2 1345
抹茶落季
抹茶落季 2021-01-13 00:55

I have a piece of SQL which (you would think) wouldn\'t compile, but which instead deletes all rows from the target table.

Consider this setup:

creat         


        
2条回答
  •  暖寄归人
    2021-01-13 01:50

    While I understand the confusion, it is behaving as it should. ColumnA is still "in scope". In fact you could join on it in your subquery if you wanted. The brackets don't limit the scope, but from a readability standpoint I can see the confusion that it creates.

    This is another example of why it's a good idea to always prefix your column names with the table name (or alias).

提交回复
热议问题