Andy897
Andy897

Reputation: 7133

SQL update query issue

I just accidentally noticed that a Query like

Update tableA tableA set id = '5'

Works fine. Should this give error as I am using table name twice here. Any thoughts why is this working fine ?

Upvotes: 3

Views: 44

Answers (2)

Ayfan
Ayfan

Reputation: 29

your code exactly equal

Update tableA as 'tableA' set id = "5"

or

Update tableA as "tableA" set id = "5"

this is simple alias as Sql Alias Tutorial

Upvotes: 2

Radu Gheorghiu
Radu Gheorghiu

Reputation: 20499

Because the second tableA is seen as an alias. There is no constraint in regards to the name of the alias, so you can have the same name on the alias as the table name.

Upvotes: 2

Related Questions