Insert into hotel('fname', 'lname'...
values
('null', 'abc'....
ON DUPLICATE KEY UPDATE
fname = 'null',
lname = 'abc',.....
Solve the above mysql query.
as you can see, you didn't enclose with single quotes the values which are not numeric,
Insert into child (`CASE`,`LASTNAME`,`FIRSTNAME`,`GENDER`,
`DOB`,`SSN`,`RACE`,`STREET`,`STREET2`,`CITY`,
`STATE`,`ZIP`,`PHONE`,`WORKPHONE`,`CELLPHONE`,
`PARENT NAME`,`GR`,`ADMITDATE`,`DISCHDATE`,
`WRK`,`WFIRSTNAME`,`WRKPHONE`)
VALUES ('null', 'Sivanesh', 'Jashawn', 'Male', '2002-03-08',
'206-80-2175', 'African American', '1689 Crucible Street',
'null', 'Pittsburgh', 'PA', '15210', '(412)458-3788',
'null', '(412)377-6079', 'Latel Williams', '2nd', '2010-03-17',
'null', 'null', 'Addison', '(412)594-2545')
ON DUPLICATE KEY UPDATE
LASTNAME = 'Sivanesh',
FIRSTNAME= 'Jashawn',...
You need to quote the values in your "KEY UPDATE" clause
Related
Error on this Query :
INSERT INTO bio(name,bioid,1101,2201,remarks,department_id)
VALUES('Julius Glenn Orienza', '575', 'FP', 'FP', 'Enroller', '10')
Use ` sign when you have column name in digit as below
INSERT INTO bio(name,bioid,`1101`,`2201`,remarks,department_id)
VALUES('Julius Glenn Orienza', '575', 'FP', 'FP', 'Enroller', '10')
insert into foo_table (fname, lname, number)
values ('John', 'Doe', if(123 = 456));
For the above MySQL query, can somebody kindly explain what the if(123 = 456) is doing? I currently struggle to see an if statement without a body (i.e. if(condition){ // do something });
The query is syntactically not correct as per mysql version 8, The syntactically correct query is insert into foo_table (fname, lname, number) values ('John', 'Doe', if(123 = 456,1,2)). This will insert 1 if the condition (123 =456) is true, otherwise it will insert 2.
I am a little bit desesperate with this query, I can't find my fault:
INSERT INTO device (
Device_UUID,
Model,
Manufacturer,
Latitude,
Longitude,
Type,
Registration_Date,
Status,
API_Source)
values (
'WW',
'a',
'v',
'0.00',
'0.00',
'BUS',
'2014-01-01 12:11:11',
'1',
'R')
ON DUPLICATE KEY UPDATE
Model = "wwww",
Manufacturer = "bbbbb",
Registration_Date = "2014-01-01 12:11:11";
All fields are String, even latitud and longitude
Type is a keyword. Try to put Type inside some ".
I exported a recordset from one database into a csv file, and when I try to import it into another using mysql workbench I keep this this error message:
Executing SQL script in server
ERROR: Error 1064: 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 ' 'Lord it Over', 'Ben', '1993-03-01', 'TRC', NULL, 1983, '1999-09-01', 'NULL', '' at line 1
INSERT INTO `TRC`.`horse`
(`horse_id`, `registered_name`, `stable_name`, `arrival_date`, `last_known_location`, `is_ex_racer`, `birth_year`, `death_date`, `horse_comments`, `sex`, `referral_date`, `horse_height`, `arrival_weight`, `passport_no`, `microchip_no`, `is_on_waiting_list`) VALUES
(, 'Lord it Over', 'Ben', '1993-03-01', 'TRC', NULL, 1983, '1999-09-01', 'NULL', 'NULL', 'NULL', NULL, NULL, 'NULL', 'NULL', 0)
SQL script execution finished: statements: 29 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
Any help would be appreciated as their appears to be no errors as far as I can see.
It's becaose of
VALUES starts with a comma.
You have missed horse_id. If it's Identity Column Then Remove horse_Id
Try like this (If horse_Id is identity)
INSERT INTO `TRC`.`horse`
(`registered_name`, `stable_name`, `arrival_date`, `last_known_location`, `is_ex_racer`, `birth_year`, `death_date`, `horse_comments`, `sex`, `referral_date`, `horse_height`, `arrival_weight`, `passport_no`, `microchip_no`, `is_on_waiting_list`) VALUES
('Lord it Over', 'Ben', '1993-03-01', 'TRC', NULL, 1983, '1999-09-01', 'NULL', 'NULL', 'NULL', NULL, NULL, 'NULL', 'NULL', 0)
Or (If Horse_id simple int then try this)
INSERT INTO `TRC`.`horse`
(`horse_id`, `registered_name`, `stable_name`, `arrival_date`, `last_known_location`, `is_ex_racer`, `birth_year`, `death_date`, `horse_comments`, `sex`, `referral_date`, `horse_height`, `arrival_weight`, `passport_no`, `microchip_no`, `is_on_waiting_list`) VALUES
('1','Lord it Over', 'Ben', '1993-03-01', 'TRC', NULL, 1983, '1999-09-01', 'NULL', 'NULL', 'NULL', NULL, NULL, 'NULL', 'NULL', 0)
^^^^ -- Here Horse_Id missing
it seems that you missing your "horse_id" value.
If that field was intended to be the Identity field, then you shouldn't mention that field on Insert Statement right?
If you want MySQL to generate an auto_increment ID for the horse_id field, you should either leave it out of the INSERT statement entirely, or specify NULL for the value in the VALUES list. You can't just leave that value empty in the list.
Your VALUES starts with a comma for some reason
I try to insert my data to some table's of database I have tried the following:
INSERT INTO tbl_18189 (a,b,c,d,e) VALUES ( '1', '4 B', '%', '0', '0')
INSERT INTO tbl_3823 (a,b,c,d,e) VALUES ( '24000', '30 M', '34%', '885', '12.05')
INSERT INTO tbl_67126 (a,b,c,d,e) VALUES ( '3.99 M', '10 B', '10%', '530', '14.41')
INSERT INTO tbl_4247 (a,b,c,d,e) VALUES ( '1', '170 M', '%', '271', '22.77')
INSERT INTO tbl_23838 (a,b,c,d,e) VALUES ( '320000', '400 M', '7%', '407', '6.91')
but I got
Error creating table: 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 'INSERT INTO tbl_38232 ...
where is the problem in my code
UNION ALL joins SELECTs and you have none in your example. Remove them.
INSERT INTO tbl_18189 (a,b,c,d,e) VALUES ( '1', '4 B', '%', '0', '0');
INSERT INTO tbl_3823 (a,b,c,d,e) VALUES ( '24000', '30 M', '34%', '885', '12.05');
INSERT INTO tbl_67126 (a,b,c,d,e) VALUES ( '3.99 M', '10 B', '10%', '530', '14.41');
INSERT INTO tbl_4247 (a,b,c,d,e) VALUES ( '1', '170 M', '%', '271', '22.77');
INSERT INTO tbl_23838 (a,b,c,d,e) VALUES ( '320000', '400 M', '7%', '407', '6.91');