Getting an error saying: Error Code: 1241. Operand should contain 1 column(s)
INSERT INTO TBL_TESTER_INFO2 (
board_id,
tester_name,
board_name,
config,
operating_system,
log_created
) VALUES (
(SELECT
bl.id as 'board_id',
bl.tester_type,
bl.board_name
FROM TesterDeviceMatrix.TBL_BOARD_LIST bl
WHERE bl.tester_type = 'UFLEX'
AND bl.board_name = 'HSD-U'
),
'tester',
'board',
'slot',
'windows',
'2015-06-10 16:08:42'
);
Any help on this? There seems to be no syntax error.
Pretty sure you can't mix a SELECT
statement with other values as part of an INSERT
statement's VALUE
set.
I'd just put the static values into the SELECT
, eg
INSERT INTO TBL_TESTER_INFO2 (...)
SELECT
bl.id,
bl.tester_type,
bl.board_name,
'slot',
'windows',
'2015-06-10 16:08:42'
FROM TesterDeviceMatrix.TBL_BOARD_LIST bl
WHERE bl.tester_type = 'UFLEX'
AND bl.board_name = 'HSD-U';
Here is the syntax of insert select SQL.
INSERT INTO table_name1(id, name,address,contact_number)
SELECT id, name, address, contact_number FROM table_name2;
In your SQL insert statement columns are not matching in select SQL.
I modified your SQL. I think it will execute
INSERT INTO TBL_TESTER_INFO2 (board_id,tester_name,board_name, config,operating_system,log_created)
SELECT bl.id AS 'board_id',bl.tester_type,bl.board_name,'slot','windows','2015-06-10 16:08:42'
FROM TesterDeviceMatrix.TBL_BOARD_LIST bl
WHERE bl.tester_type = 'UFLEX'
AND bl.board_name = 'HSD-U'
Thank you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.