0

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.

Mat
  • 202,337
  • 40
  • 393
  • 406
Leo Chan
  • 4,217
  • 8
  • 31
  • 47

1 Answers1

1

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.

Community
  • 1
  • 1
Mat
  • 202,337
  • 40
  • 393
  • 406