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

Solve the cross-domain problem of get and post requests of vue $http

Vue $http get and post request cross-domain probl...

Node.js uses express-fileupload middleware to upload files

Table of contents Initialize the project Writing ...

Example of using mycat to implement MySQL database read-write separation

What is MyCAT A completely open source large data...

Using loops in awk

Let's learn about different types of loops th...

Getting Started with Vue 3.0 Custom Directives

Table of contents 1. Custom instructions 1. Regis...

How to use macros in JavaScript

In languages, macros are often used to implement ...

Ubuntu terminal multi-window split screen Terminator

1. Installation The biggest feature of Terminator...

Summary of ways to implement single sign-on in Vue

The project has been suspended recently, and the ...

Nginx improves access speed based on gzip compression

1. Why does nginx use gzip? 1. The role of compre...

Example of how to identify the user using a linux Bash script

It is often necessary to run commands with sudo i...

How to compile and install xdebug in Ubuntu environment

This article describes how to compile and install...

CSS3 clear float method example

1. Purpose Through this article, everyone can und...

MySQL permission control details analysis

Table of contents 1. Global level 2. Database lev...