MySQL does not allow the select from statement to point to the table used for UPDATE. Of course, there is a better way than creating an endless temporary table. This article explains how to UPDATE a table and use SELECT in the query clause.
Problem
Record some select tips:
1. select statements can be separated by carriage return.
$ SQL = "select * from article where id = 1"
And $ SQL = "select * from article
Where id = 1 "can get the correct results, but sometimes it is clearer to write
MySQL does not allow the select from statement to point to the table used for UPDATE. Of course, there is a better way than creating an endless temporary table. This article explains how to UPDATE a table and use SELECT in the query clause.
Problem
Select INTO and INSERT into select two table copy statementsInsert is a common statement in T-SQL, insert into table (Field1,field2,...) VALUES (value1,value2,...)This form is essential in application development. But in the development, testing
The table looks like this
The code is as follows
Copy Code
SELECT * from ' test_table_draw ' WHERE ' borough_id ' >=10266 and ' borough_id 'huxing tableSELECT * from ' test_table_pic ' WHERE ' borough_id ' >=10266 and '
Normal query (SELECT statement used to select data from the database)
The SELECT from syntax is used to query read data from a datasheet.
Grammar:
The code is as follows
Copy Code
SELECT Column1,column1,... From
SELECT statement to remove duplicate information for a field, for example:
Tables Name: Table
ID UID Username Message dateline
1 6 a 111 1284240714 (time stamp)
2 6 a 222 1268840565
3 8 B 444 1266724527
4 9 C 555 1266723391
Execute statement (remove
If you are using MySQL or mariadb, do not use the "UTF8" encoding and use "UTF8MB4" instead.Here (HTTPS://MATHIASBYNENS.BE/NOTES/MYSQL-UTF8MB4#UTF8-TO-UTF8MB4) provides a guide for transferring the character encoding of an existing database from
Select Execution Process(8)Select (9) distinct (1) from (3) join (2) on (4)where<>(5)Group by <>(6) with{cube| ROLLUP}(7) having (ten)orderby (one)limit
Form : Calculates the Cartesian product for the table to the left of the From and
Database as a warehouse for storing data, the query can be said to be the daily operation of the database accounted for the largest proportion, and select tone can be said to be the most complex.Select is one of the DML tones, and other DML tones
This article refers to the experimental building of the SELECT statement in detail with their own operating part of the written.Note: in most systems, SQL statements are case-insensitive, but for rigorous and easy-to-distinguish reserved words and
1. If the default value is not set:SELECT userinfo.id, user_name, role, Adm_regionid, Region_name, Create_timefrom userinfoleft JOIN region on Userinfo.adm_ RegionID = Region.idResults:Set display default values:SELECT userinfo.id, user_name, role,
1. You can set collation for a table or row to binary or case sensitive. In the mysql tutorial, the naming conventions for column collate are as follows:
* _ Bin: binary case sensitive collation, that is, case sensitive.* _ Cs: case sensitive
Record some select techniques, such as how to use MySQL keywords such as IN, LIMIT, CONCAT, and DISTINCT.1. select statements can be separated by carriage return.$ SQL = "select * from article where id = 1"And $ SQL = "select * from articleWhere id =
Select *, if (SVA = 1, "male", "female") as ssva from tableame where id = 1Quote control flow Functions
Case value when [compare-value] Then result [when [compare-value] Then result...] [else result] end case when [condition] Then result [when
Concurrent UPDATE of SELECT + UPDATE in MySQL
Problem background:
Assume that the MySQL database has a vip_member (InnoDB table) member table. The structure is as follows:
When a member wants to buy a new member (only one month, three months,
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.