Using a custom field in WHERE clause of MYSQL query

by Jayanthi 2014-03-11 14:38:42

Using a custom field in WHERE clause of MySQL query

The 'status' field is not in the 'main_table'. It is created dynamic field.
But the status field checks in WHERE clause.

Use this query...create temporary table assigned to 'newtable'. Then checks custom fields.


select
*
from

(SELECT main_table.*,(case when (stage=0) then 1 else 2 end) as status FROM `main_table` WHERE usersid=20 and cid=3423 order by edate desc)

as newtable

where status=1

group by cid
1142
like
0
dislike
0
mail
flag

You must LOGIN to add comments