What is wrong with my MySQL syntax

where am I going wrong with the Syntax?
$sql = "INSERT INTO iowa (universityName) VALUES
('Des Moines College') BETWEEN universityName='Cornell College' AND universityName='Divine Word College'";

Open in new window

I know everything is spelled right, there must be a logic error
Who is Participating?
NorieVBA ExpertCommented:
If you want to just insert Des Moines then lose the Between.

You can't specify that a particular record is inserted in a particular position in a table, and you shouldn't need to anyway.
That 'BETWEEN' syntax is incorrect. You should split it into three separate inserts or insert using a SELECT:
INSERT INTO iowa (universityName) VALUES ('Des Moines College');
INSERT INTO iowa (universityName) VALUES ('Cornell College');
INSERT INTO iowa (universityName) VALUES ('Divine Word College');

Open in new window

Jagadishwor DulalBraces MediaCommented:
INSERT INTO iowas (universityName) VALUES ('Cornell College'), ('Divine Word College');

Open in new window

Ray PaseurCommented:
Have you got any nearby community colleges that teach the basics of SQL?  If so, sign up right now.  If not, this book might help you get started.  It will not make you a pro, but it will get you some foundation and will help you get "from zero to sixty" in the query language.

HTH, ~Ray
Dave BaldwinFixer of ProblemsCommented:
None of the SQL databases preserve any particular order to the rows except that defined by an ORDER BY expression in a SELECT statement.  BETWEEN doesn't work in an INSERT statement.  It is only useful to tell whether something is in a range.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.