mysql - How can I append a new result column showing the result of the WHERE clause for that row? -
instead of retrieving rows satisfying clause, intend have new result table column shows result of clause. instance;
cola colb colc newcol xxxx xxxx xxxx 1 # clause true row xxxx xxxx xxxx 0 # false row xxxx xxx xxx 0 ....
how can design such query in mysql?
you can use case statement achieve after:
select case when myfield = whatever 1 else 0 end newcol from.....
leave out clause together.
Comments
Post a Comment