You can do it this way:
UPDATE table_users SET cod_user = (case when user_role = 'student' then '622057' when user_role = 'assistant' then '2913659' when user_role = 'admin' then '6160230' end), date = '12082014' WHERE user_role in ('student', 'assistant', 'admin') AND cod_office = '17389551';
I don’t understand your date format. Dates should be stored in the database using native date and time types.
Related Posts:
- mysql update column with value from another table
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- Unknown column in ‘field list’ error on MySQL Update query
- Unknown column in ‘field list’ error on MySQL Update query
- MySQL – Operand should contain 1 column(s)
- MySQL “CREATE TABLE IF NOT EXISTS” -> Error 1050
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- MySQL create table if not exists and insert record only if table was created
- How can I do an UPDATE statement with JOIN in SQL Server?
- How do I use properly CASE..WHEN in MySQL
- How can I do a FULL OUTER JOIN in MySQL?
- MySQL query String contains
- What’s the difference between VARCHAR and CHAR?
- Case statement in MySQL
- How to declare a variable in MySQL?
- MySQL Cannot Add Foreign Key Constraint
- How to split the name string in mysql?
- How do I import an SQL file using the command line in MySQL?
- Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
- mysql Foreign key constraint is incorrectly formed error
- MySQL: Invalid use of group function
- How can I return pivot table output in MySQL?
- Compare dates in MySQL
- MySQL “WITH” clause
- MySQL Multiple Joins in one query?
- Error Code: 2013. Lost connection to MySQL server during query
- MySQL syntax for Join Update
- Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
- how to drop partition without dropping data in MySQL?
- MySQL combine two columns into one column
- Simple way to calculate median with MySQL
- Error 1046 No database Selected, how to resolve?
- MySQL Error 1264: out of range value for column
- Oracle SQL: Update a table with data from another table
- Remove duplicate rows in MySQL
- How to SUM and SUBTRACT using SQL?
- I want to use CASE statement to update some records in sql server 2005
- Cast from VARCHAR to INT – MySQL
- SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax — PHP — PDO [duplicate]
- How do you force mysql LIKE to be case sensitive?
- How to create a MySQL hierarchical recursive query?
- ERROR 1148: The used command is not allowed with this MySQL version
- Insert into a MySQL table or update if exists
- How to round down to nearest integer in MySQL?
- MySQL starts with searching issue
- Query to convert from datetime to date mysql
- Is it possible to GROUP BY multiple columns using MySQL?
- MySQL error: key specification without a key length
- Best way to test if a row exists in a MySQL table
- Check if MySQL table exists without using “select from” syntax?
- MySQL equivalent of DECODE function in Oracle
- The used SELECT statements have a different number of columns
- How to delete from multiple tables in MySQL?
- MySQL: Can’t create table (errno: 150)
- How to copy a row and insert in same table with a autoincrement field in MySQL?
- Join vs. sub-query
- updating table rows in postgres using subquery
- I want to use CASE statement to update some records in sql server 2005
- Alternative to except in MySQL
- Equivalent of explode() to work with strings in MySQL
- ROW_NUMBER() in MySQ
- MySQL OPTIMIZE all tables?
- MySQL INSERT INTO table VALUES.. vs INSERT INTO table SET
- MySQL – Get row number on select
- MySQL error: Unknown column in ‘where clause’
- How to truncate the text returned for a column in a MySQL query
- ORA-01779: cannot modify a column which maps to a non key-preserved table
- Using union and order by clause in mysql
- MySQL LIKE IN()?
- Update query using Subquery in Sql Server
- Conversion failed when converting date and/or time from character string while inserting datetime
- error, string or binary data would be truncated when trying to insert
- Using group by on multiple columns
- ORA-01843 not a valid month- Comparing Dates
- How do I escape a single quote in SQL Server?
- mysql update multiple columns with same now()
- Insert text with single quotes in PostgreSQL
- SQL Server IF NOT EXISTS Usage?
- How to insert date values into table
- How to join two tables by multiple columns in SQL?
- Arithmetic overflow error converting numeric to data type numeric
- how to remove time from datetime
- Microsoft OLE DB Provider for SQL Server error ‘80004005’
- Subtract one day from datetime
- Backup a single table with its data from a database in sql server 2008
- Is there a coalesce-like function in Excel?
- PHP Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/website/public_html/facebook/fbclogin.php on line 57 [duplicate]
- ora-06553 pls-306 wrong number or types of arguments in call to ‘ogc_x’
- How to retrieve sticky post in raw sql?
- Backticks (`) Instead of Single Quotes (‘) in an SQL Statement?
- SQL User Query by Multiple Roles using PHP
- $wpdb get_var issue
- Inserting rows into a custom table, when plugin is activated
- Posts modified in the last 48 hours
- post id not displaying
- How to run complex query using PHP
- Bulk find & replace on WordPress posts/pages (minus image paths)
- Improving performance of SQL sub-queries in WordPress
- Insert multiple checkbox values
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta