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

Solution to the problem of installing MySQL compressed version zip

There was a problem when installing the compresse...

Detailed explanation of MYSQL database table structure optimization method

This article uses an example to illustrate the me...

Detailed explanation of how a SQL statement is executed in MySQL

Overview I have recently started learning MySQL r...

How to deploy SpringBoot project using Dockerfile

1. Create a SpringBooot project and package it in...

Detailed explanation of custom swiper component in JavaScript

Table of contents Effect display Component Settin...

MyBatis dynamic SQL comprehensive explanation

Table of contents Preface Dynamic SQL 1. Take a l...

Vue routing relative path jump method

Table of contents Vue routing relative path jump ...

Mac installation mysqlclient process analysis

Try installing via pip in a virtual environment: ...

Detailed explanation of the EXPLAIN command and its usage in MySQL

1. Scenario description: My colleague taught me h...

Example code for using @media in CSS3 to achieve web page adaptation

Nowadays, the screen resolution of computer monit...

Linux Disk Quota Management Graphical Example

Disk quota is the storage limit of a specified di...

How to create Baidu dead link file

There are two types of dead link formats defined b...

MySQL tutorial DML data manipulation language example detailed explanation

Table of contents 1. Data Manipulation Language (...

Idea deployment tomcat service implementation process diagram

First configure the project artifacts Configuring...