sql server - Mysql query issue, case when column is not null insert row -


this query :

select vehicle, case  when vehicle not null (insert tbl_vehicle_on_user (vehicle, userid) values (select `vehicle` `tbl_missions` `id` = 4 ), (select `id` `tbl_users`     `id` = 12)) tbl_missions id = 4; 

i need insert row tbl_vehicle_on_user when vehicle not null on id 4. when execute query receive error mysql workbench,

01:24:49 select vehicle, case when vehicle not null (insert tbl_vehicle_on_user (vehicle, userid) values (select vehicle tbl_missions id = 4 ), (select id tbl_users id = 12)) tbl_missions id = 4 error code: 1064. have error in sql syntax; check manual corresponds mysql server version right syntax use near 'into tbl_vehicle_on_user (vehicle, userid) values (select vehicle `tbl_mi' @ line 4 0.000 sec

and red line under 'into' when hover on it, says 'syntax error, unexpected into, expecting ('.

i don't know means tried search web couldn't find if know how fix appreciate if answer question :)

thanks!!

if know userid should 12, use 12 instead of select id tbl_users id = 12. here valid insert-select statement.

insert tbl_vehicle_on_user (vehicle, userid) select `vehicle`, 12 userid  `tbl_missions`  `id` = 4 , vehicle not null; 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -