Home >Database >Mysql Tutorial >Example tutorial on processing special sql statements in mysql
The following editor will bring you a summary of the special processing statements of mysql's sql statements (must read). The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.
1. Update the entire table. If the value of a column in a row of data is empty, then let it and another The values of a column of fields are equal
UPDATE ot_tgbz set update_day=if(update_day is null,date,update_day);
2,Update the entire table, if a field is greater than 2, then update them all to 2;
UPDATE ot_user set xingyun_num=if(xingyun_num > 2,2,xingyun_num);
3, Replace all URLs containing http://www.jb51.net/ in the thumb field in the shop_goods table with empty ones.
update shop_goods set thumb= replace (thumb,'http://www.jb51.net/','') where thumb like '%http://www.jb51.net/%';
4、sql statement multi-field wherequery
$map= " CAST( `UE_account` AS CHAR CHARACTER SET utf8 ) LIKE '%$data%' OR CAST( `UE_accName` AS CHAR CHARACTER SET utf8 ) LIKE '%$data%' OR CAST( `UE_truename` AS CHAR CHARACTER SET utf8 ) LIKE '%$data%' OR CAST( `UE_phone` AS CHAR CHARACTER SET utf8 ) LIKE '%$data%'";
[Related recommendations]
2. Detailed explanation of how to write sql statements to delete tables in different databases
3. mysql 5.7 Detailed explanation of the example of changing the database data storage location
4. Detailed explanation of the error reporting method when importing mysql big data into Navicat
5. MYSQL unlock Detailed explanation of examples of lock tables
The above is the detailed content of Example tutorial on processing special sql statements in mysql. For more information, please follow other related articles on the PHP Chinese website!