Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
690 views
in Technique[技术] by (71.8m points)

mysql - SELECT INTO not working

I'd like to test a situation, but I need to add a dummy row of data to test the hypothesis. So, according to this mySQL manual page for SELECT INTO, my query is correct:

SELECT INTO courses.sections_rfip
  (SectionID, CourseID, SectionNumber, Term, Credits, CutOffDate, StartDate, EndDate, LastDateToWithDraw, ContinuousIntake, AcceptsRegistration, Fee, Instructor, SectionDescription, RegistrationRestrictions, MeetingTime, Notes, Active, Created, SetInactive)
  SELECT 3, 
         s.CourseID, 
         s.SectionNumber, 
         s.Term, 
         s.Credits, 
         s.CutOffDate, 
         s.StartDate, 
         s.EndDate, 
         s.LastDateToWithDraw, 
         s.ContinuousIntake, 
         s.AcceptsRegistration, 
         s.Fee, 
         s.Instructor, 
         s.SectionDescription, 
         s.RegistrationRestrictions, 
         s.MeetingTime, 
         s.Notes, 
         s.Active, 
         s.Created, 
         s.SetInactive 
    FROM courses.sections_rfip s
   WHERE s.sectionid = 1

But I get the following error msg:

"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 'INTO courses.sections_rfip (SectionID, CourseID, SectionNumber, Term, Credits, ' at line 1"

So there's something rotten at the INTO, which isn't obvious to me why - help?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try INSERT INTO instead: http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-select-into-table.html

EDIT: Oops. Didn't realize that was the same page you had listed. However, as it says, use INSERT INTO since SELECT INTO (from Sybase) won't work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...