Anil Namde
Anil Namde

Reputation: 6608

Help understand difference in sql query

Select user_name [User Name], first_name [First Name], last_name [Last Name] 
    From tab_user
    ORDER  BY user_name

Select user_name [User Name], first_name [First Name], last_name [Last Name] 
    From tab_user
    ORDER  BY User Name

Above are the two queries,

  1. Is there any difference because of the user_name used instead of User Name
  2. Is there something that should be taken care/worried when using something like this.

Upvotes: 0

Views: 70

Answers (3)

Mark Byers
Mark Byers

Reputation: 838106

Your second query won't work. It needs to be this:

ORDER BY [User Name]

Once this is fixed there is no difference in the results. The syntax SELECT User_Name [User Name] creates an alias.

Upvotes: 1

Amsakanna
Amsakanna

Reputation: 12934

Yes, it has to be user_name and not user uame. Space is not allowed.

Upvotes: 0

David Fox
David Fox

Reputation: 10753

the second query shouldn't work should it? you would need to

order by [User Name]

Upvotes: 1

Related Questions