Leo Chan
Leo Chan

Reputation: 4427

can sql alias can use for both column and table at the same time?

i tried it but it not works how to implement it?? thanks

eg.

Select a as columnA From TableB as b Where b.a= 'test'

Would some one suggest how to realize this sql query or how to modify it

Upvotes: 0

Views: 154

Answers (2)

rahularyansharma
rahularyansharma

Reputation: 10775

i dont know what problem you are getting. i tried this and its working fine for me.

here is the sql query and demo table

SELECT VoteTypeId AS  vcol
  FROM VoteType v 
 WHERE v.VoteTypeId = 4

and table structure is

VoteTypeId  VoteType
----------- --------------------------------------------------
1           Yes/No
2           Multiple Choice
4           Qualitative

Upvotes: 0

Justin Ethier
Justin Ethier

Reputation: 134207

I'm confused as to exactly what you are looking for, but based on your code example you may want to say:

SELECT a AS columnA 
  FROM TableB b 
 WHERE b.a = 'test'

Which would allow you to query a using table alias b.

Upvotes: 1

Related Questions