[Last Call] Learn how to a build a cloud-first strategyRegister Now


What is wrong with my MySQL syntax

Posted on 2011-05-07
Medium Priority
Last Modified: 2012-08-14
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
Question by:NewWebDesigner
LVL 11

Expert Comment

ID: 35713864
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

LVL 35

Accepted Solution

Norie earned 668 total points
ID: 35713995
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.
LVL 15

Expert Comment

by:Jagadishwor Dulal
ID: 35714080
INSERT INTO iowas (universityName) VALUES ('Cornell College'), ('Divine Word College');

Open in new window

LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 668 total points
ID: 35714088
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
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 664 total points
ID: 35714223
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.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month18 days, 5 hours left to enroll

829 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