3

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 ?

1
  • thanks for pointing out edited the question. It was a typo Commented Mar 26, 2014 at 20:37

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Ahh.. how stupid of me .. Should have guessed that :\
@Andy897 Happens to the best of us :)
2

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

2 Comments

You have the quotes the wrong way. In (standard) SQL identifiers are quoted with double quotes and string literals are enclosed in single quotes.
ooooh so sorry I am coming from mysql area so that's allowed in our area butI will add it as "or"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.