Reputation: 4427
SELECT VoteTypeId AS vcol
FROM VoteType v
WHERE v.VoteTypeId = 4
and table structure is
vcol VoteType
----------- --------------------------------------------------
1 Yes/No
2 Multiple Choice
4 Qualitative
but it turn out error and said Unknown column 'VoteTypeId' in 'where clause'
thanks in advance.
Upvotes: 0
Views: 144
Reputation: 206775
It looks like your alias is not set up reversed (but it's not entirely clear from your question), and you can't do it that way. You can't use the alias in the where clause.
If the real column name is vcol
:
select vcol as VoteTypeId from VoteType v where v.vcol = 4
See Can you use an alias is a WHERE
clause in MySQL for an explanation/links regarding why you can't use the alias in the WHERE
.
Upvotes: 1