Summary of special SQL statements for mysql (mandatory), mysqlsql

Source: Internet
Author: User

Summary of special SQL statements for mysql (mandatory), mysqlsql

1,Update the entire table. If the value of a column in a row of data is null, make it equal to the value of another field.

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, update them to 2;

UPDATE ot_user set xingyun_num=if(xingyun_num > 2,2,xingyun_num);


3,Replace the network segments containing http://www.bkjia.com/in the thumb field in the shop_goods table with all parts empty.

update shop_goods  set thumb= replace (thumb,'http://www.bkjia.com/','') where thumb like '%http://www.bkjia.com/%';


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  ) LIKE '%$data%'";

The preceding summary of special SQL statements for mysql (mandatory) is all the content that I have shared with you. I hope you can give me a reference and support me a lot.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.