You probably want to use a CASE
expression.
They look like this:
SELECT col1, col2, (case when (action = 2 and state = 0)
THEN
1
ELSE
0
END)
as state from tbl1;
More Related Contents:
- MySQL: update a field only if condition is met
- Using an IF Statement in a MySQL SELECT query
- Count with IF condition in MySQL query
- get first occurrence of last changed value of a column [closed]
- MySQL – Rows to Columns
- ROW_NUMBER() in MySQL
- How can I temporarily disable a foreign key constraint in MySQL?
- Creating a “Numbers Table” in MySQL
- MYSQL Select MAX Date inside a join statement
- Choosing a stand-alone full-text search server: Sphinx or SOLR? [closed]
- Determine which MySQL configuration file is being used
- JavaFX MySQL connection example please
- mysql select int as currency or convert int to currency format?
- MySql: is it possible to ‘SUM IF’ or to ‘COUNT IF’?
- Why do results from a SQL query not come back in the order I expect?
- MySQL combine two columns and add into a new column
- MySql difference between two timestamps in days?
- Is there a naming convention for MySQL?
- How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe? [closed]
- How to set a MySQL row to READ-ONLY?
- Finding number position in string
- Why does MySQL autoincrement increase on failed inserts?
- error code 1292 incorrect date value mysql
- How to search for rows containing a substring?
- Import CSV to Update only one column in table
- Error in MySQL library for Node.js
- The web application [] appears to have started a thread named [Abandoned connection cleanup thread] com.mysql.jdbc.AbandonedConnectionCleanupThread
- Execute INSERT if table is empty?
- Mysql How do you create a clustered index?
- MySQL data directory location