Home >Database >Mysql Tutorial >Mysql 4 sql statement special processing statement summary (collection)

Mysql 4 sql statement special processing statement summary (collection)

PHPz
PHPzOriginal
2017-04-03 17:46:311493browse

The following editor will bring you a summary of the special processing statements of mysql's sql statements (must read). The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. 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 where query

$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

The above is the detailed content of Mysql 4 sql statement special processing statement summary (collection). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn