Solved

how can I modify table structure to make this query run

Posted on 2013-01-13
2
379 Views
Last Modified: 2013-01-13
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




how can I modify table structure to make this query run

to add to column description in that row where email1 is there
0
Comment
Question by:rgb192
2 Comments
 
LVL 24

Accepted Solution

by:
johanntagle earned 500 total points
ID: 38772925
There's no need to modify the table.  You just need to correct your insert statement.  Please take time to look at the manuals and check the correct syntax for the command you are using.  See http://dev.mysql.com/doc/refman/5.5/en/insert-on-duplicate.html

After ON DUPLICATE KEY UPDATE there's no need to repeat the table name nor use the keyword "set".  It should just be:

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

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 38773170
ON DUPLICATE KEY UPDATE

works

and
my query had too many words

and thanks for the link
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now