?
Solved

concat on duplicate key unique constraint email1

Posted on 2013-01-12
7
Medium Priority
?
793 Views
Last Modified: 2013-01-13
I am using php/mysql


UC is email1

INSERT INTO renters (first_name,last_name,email1,email2,email3,phone1,phone2,phone3,information,description) VALUES ('TEST','','derrickjmiller1@gmail.com','','','','','','','
\r\n	ADD THIS PLEASE

\r\n') ON DUPLICATE KEY UPDATE renters set description=concat (description,'
\r\n	ADD THIS PLEASE

\r\n');

Open in new window


Error Code: 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 'set description=concat (description,' \r\n ADD THIS PLEASE  \r\n')' at line 1
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 25

Expert Comment

by:TempDBA
ID: 38771102
Can you be more clear with your requirements along with an example?
0
 

Author Comment

by:rgb192
ID: 38771114
insert a new row
or
add to column description
if email1 is already in the table
0
 
LVL 11

Accepted Solution

by:
mcnute earned 2000 total points
ID: 38771720
Well your query isn't quite finished in the code you posted. This should do it:

ON DUPLICATE KEY UPDATE renters set description=concat (description,'somthing to add to description')";

Open in new window

0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

Author Comment

by:rgb192
ID: 38772148
what is difference between your code

ON DUPLICATE KEY UPDATE renters set description=concat (description,'somthing to add to description')";

and

INSERT INTO renters (first_name,last_name,email1,email2,email3,phone1,phone2,phone3,information,description) VALUES ('TEST','','derrickjmiller1@gmail.com','','','','','','','
\r\n      ADD THIS PLEASE

\r\n') ON DUPLICATE KEY UPDATE renters set description=concat (description,'
\r\n      ADD THIS PLEASE

\r\n');




maybe a
'
0
 

Author Comment

by:rgb192
ID: 38772529
delimiter $$

CREATE TABLE `renters` (
  `id` int(11) NOT NULL auto_increment,
  `first_name` varchar(100) default NULL,
  `last_name` varchar(100) default NULL,
  `email1` varchar(100) default NULL,
  `email2` varchar(100) default NULL,
  `email3` varchar(100) default NULL,
  `phone1` varchar(20) default NULL,
  `phone2` varchar(20) default NULL,
  `phone3` varchar(20) default NULL,
  `information` varchar(4000) default NULL,
  `description` varchar(9000) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `email1` (`email1`)
) ENGINE=MyISAM AUTO_INCREMENT=32 DEFAULT CHARSET=utf8$$








INSERT INTO renters (first_name,last_name,email1,email2,email3,phone1,phone2,phone3,information,description) VALUES ('test','','derrickjmiller1@gmail.com','','','','','','','') ON DUPLICATE KEY UPDATE renters set description=concat(description,'somthing to add to description')

Error Code: 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 'set description=concat(description,'somthing to add to description')' at line 1
0
 

Author Closing Comment

by:rgb192
ID: 38772536
this would work with if I have a correct uc and no primary key

so your answer is correct

I need another question about table structure
0
 
LVL 25

Expert Comment

by:TempDBA
ID: 38772540
your syntax is wrong.
instead of adding the table name again,
ON DUPLICATE KEY UPDATE renters set description=concat (description,'
 it should be
ON DUPLICATE KEY UPDATE  description=concat (description,'
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question