I need to change some domain name into a table containing e-mail addresses (primary key).
I tried to extract (with a select
) the fields that I need to update:
SELECT `Email`, CONCAT(
SUBSTRING_INDEX(`Email`, '@olddomain.', 1),
'@newdomain.',
SUBSTRING_INDEX(`Email`, '@olddomain.', -1)) AS NewMail
FROM `mailaddresses`
WHERE INSTR(`Email`,'@olddomain.')>0
This works fine and gives me old and new e-mails.
Follows an example of the returned data:
EMail NewMail
123@olddomain.com 123@newdomain.com
456@olddomain.com 456@newdomain.com
789@olddomain.com 789@newdomain.com
So I tried to update using the following query:
UPDATE `mailaddresses`
SET `Email` = CONCAT(
SUBSTRING_INDEX(`Email`, '@olddomain.', 1),
'@newdomain.',
SUBSTRING_INDEX(`Email`, '@olddomain.', -1))
WHERE INSTR(`Email`, '@olddomain.')>0
But phpMyAdmin is saying that there's an SQL syntax error.
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1) '@newdomain.' SUBSTRING_INDEX(
mailaddresses
WHER' at line 2
I noticed that two commas ',' are missing in the error message so I think phpMyAdmin is doing something nasty there.
EDIT:
I realized that my SQL code is fully working because I tested it on a MySQL console and it's working fine. I think I have problems with PhpMyAdmin (I don't know what kind of problems though).
Here some data from my Xampp/PhpMyAdmin home page:
Database server
Server: 127.0.0.1 via TCP/IP
Server type: MySQL
Server version: 5.6.24 - MySQL Community Server (GPL)
Protocol version: 10
Web server
Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8
Database client version: libmysql - mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $
PHP extension: mysqli
phpMyAdmin
Version information: 4.3.11
I'm sure of this because I ran my SQL code from vb.net and it worked.
So my questions are:
Is there anyone who has had the same problem?
How can I solve this?