Summary of special processing statements of MySQL SQL statements (must read)

Summary of special processing statements of MySQL SQL statements (must read)

1. Update the entire table. If the value of a column in a row of data is empty, make it equal to the value of another column 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 all to 2.

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


3. Replace all the URLs containing https://www.jb51.net/ in the thumb field of the shop_goods table with empty ones.

update shop_goods set thumb= replace (thumb,'https://www.jb51.net/','') where thumb like '%https://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
  ) LIKE '%$data%'";

The above summary of MySQL's special processing statements in SQL (must read) is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Some common SQL statements in MySQL
  • Super detailed SQL statement syntax summary
  • A brief discussion of 30 common methods for optimizing SQL query in MySQL
  • 10 tips for optimizing MySQL SQL statements
  • MySQL's most basic SQL syntax/statements
  • Summary of MySql Common Operation SQL Statements
  • mysql partial replacement sql statement sharing
  • Mysql primary key related sql statement collection

<<:  Vue project configures webpack-obfuscator to implement code encryption and obfuscation

>>:  How to deploy tomcat in batches with ansible

Recommend

Introduction to 10 Hooks in React

Table of contents What is ReactHook? React curren...

Docker+nextcloud to build a personal cloud storage system

1. Docker installation and startup yum install ep...

CSS3 animation – steps function explained

When I was looking at some CSS3 animation source ...

Automatically install the Linux system based on cobbler

1. Install components yum install epel-rpm-macros...

Detailed explanation of Socket (TCP) bind from Linux source code

Table of contents 1. A simplest server-side examp...

Two usages of iFrame tags in HTML

I have been working on a project recently - Budou...

MySQL Learning: Three Paradigms for Beginners

Table of contents 1. Paradigm foundation 1.1 The ...

Vue project realizes paging effect

The paging effect is implemented in the vue proje...

Detailed explanation of the process of building and running Docker containers

Simply pull the image, create a container and run...

JavaScript to achieve digital clock effects

This article example shares the specific code for...

Solution to the data asymmetry problem between MySQL and Elasticsearch

Solution to the data asymmetry problem between My...

Detailed explanation of Vue's calculated properties

1. What is a calculated attribute? In plain words...

WeChat applet implements the snake game

This article shares the specific code of the WeCh...