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?
Related
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
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.
I am updating the data by the following method
class xxxxxx
{
public static string updatepersonformData(string staffID, string Firstname, string Lastname, string Address1,
string Address2,string Address3, string Town, string County, string Postcode, string HomePhone, string Mobile,
string PersonalEmail, string Reference, string BookingName, string Position_Id, string Role_Id, string Gender,
string Dob, string WorkPhone, string WorkEmail, formMain mf)
{
string result = xxxxxx.InsertData(string.Format(#"update staff set staff_Reference='{2}' staff_Firstname = '{3}',staff_Lastname='{4}' ,
staffPosition_Id='{5}',staffRole_Id='{6}', staff_Dob='{7}',staff_Gender='{8}' staff_Address1 = '{9}',
staff_Address2='{10}',staff_Address3 ='{11}' staff_Town ='{12}',staff_County = '{13}',staff_Postcode='{14}',staff_HomePhone='{16}',
staff_WorkPhone ='{17}',staff_Mobile ='{18}',staff_PersonalEmail ='{19}',staff_WorkEmail='{20}',staff_BookingName='{21}',WHERE staff_Id ={0}",
staffID, Reference, Firstname, Lastname, Position_Id, Role_Id, Dob, Gender, Address1, Address2, Address3, Town, County, Postcode, HomePhone, WorkPhone,
Mobile, PersonalEmail, WorkEmail, BookingName), mf);
return result;
}
}
I am calling this function in main form by using this below
xxxxxx.updatepersonformData(tbCStaffHiddenId.Text, tbFirstname.Text, tbLastname.Text, tbAddress1.Text, tbAddress2.Text, tbAddress3.Text, tbTown.Text,
tbCounty.Text, tbPostcode.Text, tbHomePhone.Text, tbMobile.Text, tbPersonalEmail.Text, tbReference.Text, tbBookingName.Text, selectTextToId(cbPosition, aaPositions),
selectTextToId(cbRole, aaRoles), cbGender.Text, tbDob.Text.ToString(), tbWorkPhone.Text, tbWorkEmail.Text, mf);
But when I am updating this one I got the error like this......
Error: "Index (zero based)
must be greater than or equal to zero
and less than the size of the argument
list.
Make sure your method arguments are in
right form.
When converting a string to date time,
parse the string to take the date
before putting each variable into the
date time object.
Can anyone help on this ...
You're passing 20 arguments to string.Format, but your format placehorlders go from 0 to 21 (so presumably you need 22 arguments, or you've misindexed the thing - e.g. I don't see a {15} in there). Recheck your string and arguments until that formatting error is resolved.
And you have a syntax error in your query. The should not be a , before the WHERE keyword.
(And please use bind variables if they are available on whatever system/language it is you are using, and sanitize your data, otherwise bad things will happen - google for "sql injection".)
Sorry, User682417, but this is all kinds of messy.
I'm pretty sure you've got the indexing of the parameters wrong - you set
staff_Reference='{2}'
but it's at index 1 - is it possible you need to decrement each of the indices?
Also, SQL injection. But others have said that already.
Also, in the unlikely event you're passing the date of birth in correctly, you're assuming your client and your database have the same date formatting - but Europeans usually enter dd/mm/yyyy, whilst Americans often enter mm/dd/yyyy. Great source of comedy bugs, that one.
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'
);
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.