sql - Strange data swapping error occurs when I attempt to update rows in my table from another table in MySQL database -
So I have 10,000 data lines that have long lines only about one of the many column columns in the table of information Describe, that is, only one column has the content, and the remaining columns describe the condition of the content (for its book). Right now, only 6,000 of the content columns in the 10,000 rows are full of its content Rows 6-10,000 Content columns simply say null
I have another table in DB, in which the content for rows is 6,000-10,000 It is easy to update (line up) the 10,000 line table with the correct primary key.
I'm trying to query the update as:
UPDATE table (10,000) SET content_column = (select content from the table (6,000 -10,000) WHERE Table (10,000) .id = Table (6-10,000.id)
What kind of work is, only one problem is that it is fine in data from another table Pulls it, but it replaces the existing content column with spaces, then the content column of lines 1-6,000 becomes zero, and the rows are 6-10,000 The correct columns are in the column column ... I thought in a very strange way.
Is there any idea about someone what's wrong with me? If you can show me a better SQL query I appreciate it, thanks!
The reason is that you have no where, Therefore updating all the rows is following the following queries that are present in the 6K-10K table only
Set up an update table (10,000) content_column = (select the content from the table (6,000-10,000) where the table (10,000) .id = table (6-10,000.id)) where exists (select 1 (6,000-10,000) from the table where the table (10,000) .id = table (6-10,000.id))
Another way is if you do not want to overwrite the existing values, then the collages must be used:
Set Up Update Table (10,000) content_column = Coalesce (table (10,000) .content_column , (From the table Choose the content (6,000-10,000) where the table (10,000) .id = table (6-10,000.id)))
E
Comments
Post a Comment