Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

concat on duplicate key unique constraint email1

Posted on 2013-01-12
7
Medium Priority
?
800 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

618 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