Home > Database > Mysql Tutorial > body text

Mysql 4 sql statement special processing statement summary (collection)

PHPz
Release: 2017-04-03 17:46:31
Original
1462 people have browsed it

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);
Copy after login

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);
Copy after login

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/%';
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!