Mysql Insert Select Error 1064
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this
Mysql Error 1064 Insert 42000
site About Us Learn more about Stack Overflow the company Business Learn more mysql error 1064 insert into about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x
Mysql Error 1064 (42000)
Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL INSERT mysql error 1064 create table INTO … SELECT throws Error 1064 up vote 2 down vote favorite 1 Trying to duplicate some rows in a table but just change the ssreportid column from 4 to 6: INSERT INTO ssreportparticipant (ssreportid, sssurveyparticipantid) VALUES SELECT 6, sssurveyparticipantid FROM ssreportparticipant WHERE ssreportid = 4 The error says #1064 near 'select 6, ...' but if I just run the select clause, it selects the error 1064 mysql 42000 create table records perfectly, with the new id of 6 in the ssreportid column. The table has a primary key called ssreportparticipantid, and there is a unique key on (ssreportid, sssurveyparticipantid). Note that the select clause creates new records that have unique key pairs, so that's not the problem. I have tried putting brackets around the select clause, and even using two aliases for the table, no joy. Using server version 5.0.45. Please tell me that programmer fatigue has me missing a comma or something. Thanks, -Josh mysql select insert share|improve this question edited Apr 23 '13 at 14:59 JNK 41.3k476106 asked Feb 27 '09 at 8:09 iopener 3711623 add a comment| 2 Answers 2 active oldest votes up vote 7 down vote accepted I think you should remove "VALUES" share|improve this answer answered Feb 27 '09 at 8:13 ybo 11.6k21931 Thank you. Thank you. I am an idiot and totally FAILZ at reading the manual. –iopener Feb 27 '09 at 8:17 Correct. Values is used when the values are given: insert into ssreportparticipant (ssreportid, sssurveyparticipantid) VALUES (6, 20) In this case the select statement provides the values. &
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of
Mysql Error Code 1064 Insert
this site About Us Learn more about Stack Overflow the company Business Learn mysql insert into more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up http://stackoverflow.com/questions/593929/mysql-insert-into-select-throws-error-1064 ERROR 1064 (42000) - MySQL error in INSERT … SELECT query up vote 0 down vote favorite As part of a MySQL trigger I'm writing, I've got an INSERT ... SELECT query that is returning : ERROR 1064 (42000) at line 7: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax http://stackoverflow.com/questions/25309714/error-1064-42000-mysql-error-in-insert-select-query to use near 'pp2 (curr_code, pricing_id, pid, title, startdate, enddate, priority, enabled) S' at line 33 INSERT INTO product_pricing pp2 (curr_code, pricing_id, pid, title, startdate, enddate, priority, enabled) SELECT cc, `pp1`.`pricing_id`, `pp1`.`pid`, `pp1`.`title`, `pp1`.`startdate`, `pp1`.`enddate`, `pp1`.`priority`, `pp1`.`enabled` FROM product_pricing pp1 WHERE pp1.pp_id = NEW.pp_id ON DUPLICATE KEY UPDATE pp2.pp_id=(SELECT newppid := pp2.pp_id); I'm not sure if it's the cc part? That's a declared variable in the trigger but it should work given that you should be able to do a SELECT 'hello', t.col1 FROM table t Any suggestions as to what the error is greatly received. mysql sql share|improve this question edited Aug 14 '14 at 13:56 Barranka 12.4k82859 asked Aug 14 '14 at 13:50 glambert 4915 First thing : INSERT INTO [...] VALUES [...] is the syntax. Where is your VALUES ? –Kabulan0lak Aug 14 '14 at 13:58 @Kabulan0lak There's also INSERT INTO ... SELECT. The SELECT provides the values. –Thorsten Dittmar Aug 14 '14 at 14:00 @ThorstenDittmar Hum ok I didn't know. Thanks ! –Kabulan0lak Aug 14 '14 at 14:14 add a comment| 2 Answers 2 active oldest votes up
Search Username Password Remember Me? Register Lost Password? facebook google twitter rss Free Web Developer Tools Advanced Search Forum Databases MySQL Help Getting an http://forums.devshed.com/mysql-help/930294-getting-error-1064-insert-statement-post2818802.html error #1064 with an INSERT statement?????? Thread: Getting an error #1064 with an INSERT statement?????? Share This Thread Tweet This + 1 this Post To Linkedin Subscribe https://bugs.mysql.com/bug.php?id=15509 to this Thread Subscribe to This Thread September 7th, 2012,10:37 AM #1 No Profile Picture dlmagers View Profile View Forum Posts Visit Homepage Registered User Devshed error 1064 Newbie (0 - 499 posts) Join Date Jun 2011 Location Rocky Mount, NC Posts 16 Rep Power 0 Getting an error #1064 with an INSERT statement?????? The statement is Code: INSERT INTO gtr_shop1_products (categoryID, productCode, productName, listPrice) VALUES (1, ‘tele’, ‘Fender Telecaster’, 599.00); From what I can see the statement looks correct. I am getting an error mysql error 1064 of #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 'Telecaster’, 599.00)' at line 1 Would someone help me understand this? Thank you. Faq Reply With Quote September 7th, 2012,11:00 AM #2 Guelphdad View Profile View Forum Posts Hockey face Devshed Supreme Being (6500+ posts) Join Date Nov 2001 Location St. Catharines, Canada Posts 8,142 Rep Power 1318 try using single quote marks like ' instead of the quotes you are using. they may be getting translated incorrectly. Comments on this post paulh1983 agrees : it definitely is that. Faq Reply With Quote September 7th, 2012,11:27 AM #3 No Profile Picture dlmagers View Profile View Forum Posts Visit Homepage Registered User Devshed Newbie (0 - 499 posts) Join Date Jun 2011 Location Rocky Mount, NC Posts 16 Rep Power 0 Thanks That wor
Coldrey Email Updates: Status: Not a Bug Impact on me: None Category:MySQL Server Severity:S3 (Non-critical) Version:4.1.16 OS:Linux (linux) Assigned to: Aleksey Kishkin View Add Comment Files Developer Edit Submission View Progress Log Contributions [6 Dec 2005 3:07] Paul Coldrey Description: When I try to insert into a table called Version I get the error: "ERROR 1064 (42000) at line 5: 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 'Version(Id INTEGER)' at line 1". It seems to be specific to the table name, but Version seems to be acceptable in other commands like CREATE TABLE, DROP TABLE, SELECT and it is not listed in the reserved words. My my.ini file is: -- Start of my.ini -- [mysqld] set-variable = lower_case_table_names=OFF -- End of my.ini -- >mysql --version mysql Ver 14.7 Distrib 4.1.8, for Win95/Win98 (i32) The behaviour is the same in version 4.1.8 How to repeat: DROP DATABASE IF EXISTS bugme8; CREATE DATABASE bugme8; USE bugme8; CREATE TABLE Version(Id INTEGER); INSERT INTO Version(Id) VALUES (1); -- Note that if you replace the above two lines with the two below then it works -- as I would have expected (ie no error) -- CREATE TABLE Wersion(Id INTEGER); -- INSERT INTO Wersion(Id) VALUES (1); [6 Dec 2005 3:12] Paul Coldrey Apologies, I copied the version string from before I upgraded to the latest release. Actual version is: >mysql --version mysql Ver 14.7 Distrib 4.1.15, for Win32 (ia32) [6 Dec 2005 6:34] Aleksey Kishkin Paul your error message looks like from 'create table' command. Could you confirm it appears after 'insert' command? [6 Dec 2005 10:16] Paul Coldrey Thanks for the prompt feedback. Mea Culpa. Indeed my test case did not show the behaviour I was trying to show. Here is a slightly more wordy version which elicits the issue: DROP DATABASE IF EXISTS bugme8; CREATE DATABASE bugme8; USE bugme8; CREATE TABLE Version ( Id INTEGER PRIMARY KEY AUTO_INCREMENT, Data VARCHAR(255) ); INSERT