Error parsing the query token line error - sql

I am trying to enter fictional values into a table I created with columns. I am getting this error:
Major Error 0x80040E14, Minor Error 25501
insert into employees (`first`, `last`, `title`, `age`, `salary`)
values (`Jonie`, `Weber`, `Secretary`, `28`, `19500`))
There was an error parsing the query. [ Token line number = 2,Token line offset = 2,Token in error = ` ]
I have entered:
insert into employees (`first`, `last`, `title`, `age`, `salary`)
values (`Jonie`, `Weber`, `Secretary`, `28`, `19500`));
What am I doing incorrectly?

You need to put quotes around strings, not backticks:
insert into employees (first, last, title, age, salary)
values ('Jonie', 'Weber', 'Secretary', 28, 19500)
And you have a ) too much at the end.

Related

Access 2007, INSERT INTO (...) Values (...) throws Syntax error

INSERT INTO Employees (fname, lname, address, city, state, zip, phone)
VALUES ('Gustavo', 'Fring’, "125 Birdy Lane", ‘Tucson’, ‘AZ’, #85705#, #520-535-5323#);
Error code: "Syntax error in query expression "Fring’, "125 Birdy Lane", ‘Tucson’, ‘AZ’, #85705#, #520-535-5323#);.
For the life of me I can not figure this out.
Are the hash symbols # supposed to be part of the inserted strings?
Also you need to use normal single quotes '' for all strings, not typographic ones ‘’.
VALUES ('Gustavo', 'Fring', '125 Birdy Lane', 'Tucson', 'AZ', '85705', '520-535-5323')
I'm not sure why you are putting " around the address and # around the numbers. Doesn't ' work?

Error in the SQL query

Can't figure out what is wrong with the following SQL query:
INSERT into ALL (name, address, client_id, service_id, service, service_address) values
('Товарищество с ограниченной ответственностью "King Fisher"',
'г.Алматы, ул.Айманова, 155, уг.ул.Жандосова','10','10','Интернет(1024)/10','г.Алматы, ул.Айманова, д.155, уг.Жандосова');
Here is an error output:
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 'ALL (name, address, client_id, service_id, service, service_address) values ('' at line 1
Any help would be appreciated)
ALL is a reserved keyword. Because of this, it is necessary to wrap the table name in backticks:
INSERT into `ALL` (name, address, client_id, service_id, service, service_address) values
('Товарищество с ограниченной ответственностью "King Fisher"',
'г.Алматы, ул.Айманова, 155, уг.ул.Жандосова','10','10','Интернет(1024)/10','г.Алматы, ул.Айманова, д.155, уг.Жандосова');
See:
http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html
you have not closed the ' quotes, check and try or try using brackets

Active Record query causing SQLException near "," syntax error

I'm trying to display all such rows of a table STUDENTS which have a value of an attribute, such as COURSE IN a set of given values e.g. 'MS', 'PhD'.
I get the values in the students_controller.rb file using params. I tried to run an Active Record query using where to do the job:
#all_courses = ['MS', 'PhD', 'BA', 'MSc']
#students = Student.where("course IN :courses" , {:courses => params.has_key?(:courses) ? params[:courses].keys : #all_courses})
But I get the following error:
SQLite3::SQLException: near ",": syntax error: SELECT "students".* FROM "students" WHERE (course IN 'MS', 'PhD', 'BA', 'MSc')
I think the error might be due to the absence of ; at the end of the SQL query generated by Active Record, but I cannot do anything to get that semicolon at the end.
You need to use parentheses: "course IN (:courses)"

appcelerator escape query string

I'm looking for a way to escape all characters in javascript so i can insert them into a database. But i don't want to use escape() because that's breaking my code.
now getting this error:
[ERROR] invalid SQL statement. Error Domain=com.plausiblelabs.pldatabase Code=3 "An error occured parsing the provided SQL statement." UserInfo=0x6de2b50 {com.plausiblelabs.pldatabase.error.vendor.code=1, NSLocalizedDescription=An error occured parsing the provided SQL statement.
com.plausiblelabs.pldatabase.error.query.string=INSERT INTO vac ( category, title, url, description) VALUES ( '201', ' Adviseur Bankshop', 'someurl', 'description \'t more text.')
You can use parameters in Appcelerator.
DB.db.execute(
"INSERT INTO feeds (title, description) VALUES (?, ?)",
'Good News!', 'A little description'
);

SQLAlchemy ProgrammingError - how to debug?

I'm using SQLAlchemy 0.5.8, and seeing this error:
ProgrammingError: (ProgrammingError) can't adapt 'INSERT INTO enumeration_value (id,
key_id, code, name, notes) VALUES (%(id)s, %(key_id)s, %(code)s, %(name)s, %(notes)s)'
{'key_id': 'aac6fc29-4ccd-4fe4-9118-cfbbd04449fe', 'notes': '', 'code': (u'Barnet',),
'id': 'd0540c97-882e-4a5b-bf14-b3ebcfeea051', 'name': (u'Barnet',)}
But a direct SQL insert with the values from the error seems to work just fine:
=> INSERT INTO enumeration_value (id, key_id, code, name, notes)
VALUES ('d0540c97-882e-4a5b-bf14-b3ebcfeea051', 'aac6fc29-4ccd-4fe4-9118-cfbbd04449fe',
'Barnet', 'Barnet', '');
INSERT 0 1
If the direct SQL works OK, how can I start to debug this?
Incidentally, the line that's throwing the error doesn't seem to have an INSERT statement in it at all, so I am a bit confused:
File "----barnet.py", line 117, in load_file
instance = model.Session.query(model.EnumerationValue).filter_by(key=key_barnet_level_2, code=level_2).all()
Do SQLAlchemy filter statements generate INSERT commands, or does this just happen to be the last line before things start to go wrong?
Figured it out - the problem was actually a syntax error a few lines higher up, with a rogue comma:
key_from = code,
Sorry if I wasted anyone's time. Please close the question.