Here is my code.


INSERT INTO employees
(1.Last_Name,2.First_Name,3.Title,4.Title_of_Courtesy5.,BD,6.Hire_Date,7.Address,8.City,9.State,10.Zip,11.Country,12.Extension,13.Notes,14. Reports_to,15.Photo);
VALUES (1, 'Smith', 'Janet', 'Sales Manager', 'Mrs.', '12-30-1974', '08/05/2000', '123 My Street', 'canton', 'OH', '44720', 'USA', '4632', 'MBA from Ashland University', 'Andrew Fuller', 'No Photo Available Yet');

Here is error message...Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'Last_Name'.

Recommended Answers

All 3 Replies

Into what column do you want the first value (1) to be put?

Hello,

Ok. I see a couple of things that are a little off:

1. Why do you have a number as part of the field name? And do you have an ID field (record number that auto-increments)?

2. There should be a space after each field name.

3. A semi-colon (the one after "Photo); " and before "VALUES" ) ends a sql statement so instead of one you have two separate statements that are missing the other half. Remove the semi-colon.

4. Your field list shows you inserting to Last_Name then First_Name but your value list starts with
1, 'Smith', 'Janet'

So the system is trying to insert 1 into the Last_name field.

5. You have your dates in two different formats which may cause a problem depending on the version of MySQL.


If I may.... try this instead:


INSERT INTO employees
(Last_Name, First_Name, Title, Title_of_Courtesy, BD, Hire_Date, Address, City, State, Zip, Country, Extension, Notes, Reports_to, Photo)
VALUES ('Smith', 'Janet', 'Sales Manager', 'Mrs.', '12-30-1974', '08/05/2000', '123 My Street', 'canton', 'OH', '44720', 'USA', '4632', 'MBA from Ashland University', 'Andrew Fuller', 'No Photo Available Yet');

Here is error message...Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'Last_Name'.

the error is beacuse your field(or column ) name is like 1.Last_Name. you may use [1.Last_Name] instead.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.