Generally speaking. How to check whether the contents of the two tables are consistent, this demand is mostly reflected from the machine, to ensure data consistency. There are two methods, the first one is to start with the database. The second is
A student asked me, in a scenario similar to pt-osc, how can we ensure that the two table names are correct? The analysis estimated that other students laughed. Isn't table name correct easy? RENAME each other. However, what we want is to complete
One, union query usage
The union query is simpler, as if the two tables were merged and the fields were combined
If it is
SELECT * FROM table1, table2
Words, two of the same fields will not be merged but
Select A1 from table1 Union Select A1
In general, how to detect the content of the two tables is consistent, such requirements are mostly reflected from the machine to ensure data consistency. There are two methods, the first is to start from the database, the second is to start from
When the data volume is small, the subquery can be used to do two table association operations, but the sub-query efficiency is too low when the data volume is large (because it is a single pair)Like what:Update Person1 p1 set p1.p_name= (select
Select * into from Srctbl Insert into Select 5 from SrctblAs above Desttbl and SRCTBL are two table names respectively.The above two sentences are inserted srctbl data into the DESTTBL, but the two sentences are different:
The first
Implementation Code of the Yii2.0 widget GridView (two-table joint query/search/paging) function, yii2.0gridview
Join query/search/paging of two tables in the GridView
When we display active data in a grid view, you may encounter this situation,
Problem Description:Two Tables A and B, each with a field, update time A.MODIFIED_TM and B.modified_tm,a table as the main table, update time is not empty, but the B table update time may be empty, now to take a, B two table time the newest one,
Objective
Before the practice encountered a problem, in a similar pt-osc scenario, you need to swap two table names, how to ensure the foolproof?
Analysis
Some people may think, the table name is not easy to drop, rename each other.
However,
The assertion that exists is more efficient than in is inaccurate.If the two table size of the query is equal, then the in and exists are not very different.If one of the two tables is smaller and one is a large table, then the subquery table is
"How to update with views"There is a need for a table, B table, the Name field in table B is updated to the name in table A, two tables have ID associated with the code as follows:Update (select A.name aname, B.name bname from a, b b where a.id =
When you look at the MySQL 5.1 reference manual, you find that MySQL provides a two-table associated update operation. The original text reads as follows:UPDATE items,monthSET items.price=month.PriceWHERE items.id=month. ID;Constructs a table in
PostgreSQL Two-table joint updateRecently use PostgreSQL feel a bit useless, a joint update is not to write this syntax to:Update D_routetripSet Name=b.name,Description=b.descriptionFrom D_scenery as Bwhere foreignid=b.id and d_routetrip.type= '
Two-table-connected SQL statement: Which is the best way to do this? Which one is advocated now?
For example: a two-table-connected SQL has two ways of writing:(1) Select A.c1,a.c2,b.c1,b.c2From table1 a,table2 Bwhere a.id=b.id
(2) Select A.c1,a.c2,
CREATE TABLE as SELECT * FROM and insert to select from two table copy statement differences[SQL]View PlainCopy
Create table targer_table as select * from source_table
INSERT INTO target_table (column1,column2) select Column1,column2
Recently in the work of data migration, the old system of data migration to the new system, there is a lot of trouble, because it is a redesigned system and the old system has too many inconsistencies, such as table structure, field processing, such
SQL Associated Query & Modify fields, the correct example is as follows:--Batch Change report unit name & Update time--TT and TP Two Table association query, update the principal field in the Eligible TT table to the Ruperson field of the TP table
In general, how to detect the content of the two tables is consistent, such requirements are mostly reflected from the machine to ensure data consistency. There are two methods, the first is to start from the database, the second is to start from
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.