I am at a loss this morning. Maybe my coffee was drugged? Simple problem- get the existing ids into this temp table for an export.
Tables like so:
Table person
+--------+-----------------------+
| id | email |
+--------+-----------------------+
| 142755 | xxxxxxx@xxxxxxxxx.com |
+--------+-----------------------+
Table no_dma
+--------+-开发者_Go百科-----------------------+
| person | email |
+--------+------------------------+
| 0 | xxxxxxx@xxxxxxxxx.com |
+--------+------------------------+
Query:
UPDATE
person, no_dma
SET no_dma.person = person.id
WHERE person.email = no_dma.email;
I have verified the existence of at least some matching email addresses in the two tables but the update produces
Query OK, 0 rows affected (9.31 sec)
Rows matched: 0 Changed: 0 Warnings: 0
Clearly I have a little dain bramamge today.
Help me out? What am I doing incorrectly?
// EDIT
Per comments below I made these queries:
mysql> select person, email from no_dma limit 0,1;
+--------+------------------------+
| person | email |
+--------+------------------------+
| 0 | tom_r1989@xxxxxxx.com
+--------+------------------------+
1 row in set (0.00 sec)
mysql> select email from no_dma where email = 'tom_r1989@xxxxxxx.com';
Empty set (0.00 sec)
mysql> select email from no_dma where TRIM(email) = 'tom_r1989@xxxxxxx.com';
Empty set (0.46 sec)
Both tables have email field stored as varchar with collation set to latin1_swedish_ci.
And this this query, WTH?
mysql> SELECT CONCAT('"',email,'"') from no_dma limit 0,3;
+-----------------------+
| CONCAT('"',email,'"') |
+-----------------------+
" |amjor308@xxx.com
" |utt@xxx.com
" |00000000@xxx.com
+-----------------------+
mysql> SELECT email from no_dma limit 0,3;
+--------------------+
| email |
+--------------------+
|+amjor308@xxx.com
|mutt@xxx.com
|000000000@xxx.com
+--------------------+
What is going on there? Looks like newlines but I thought TRIM() handled those?
mysql> SELECT TRIM(email) from no_dma limit 0,3;
+--------------------+
| TRIM(email) |
+--------------------+
|+amjor308@aol.com
|mutt@excite.com
|000000000@aol.com
+--------------------+
3 rows in set (0.00 sec)
UPDATE: FOUND ISSUE import was done on a Windows generated CSV but mysqlimport was given arg
--lines-terminated-by='\n'
Reimported data works fine. Sorry to have wasted folks time.
Table no_dma has a trailing space. The data is not the same.
Edit:
- SET ANSI_PADDING?
- Is it really a space:
is ASCII 160 - What does a hash or checksum of each value reveal?
- What are the string lengths?
The statement is fine, I think. B/c I tested it and it worked.
精彩评论