mysql - Executing an update statement with a select subquery clause in C -


i have following sql run in c:

snprintf(sql, 200, "update rec set name = (select name pers id = %d )  id = %d",rec_id , emp_id ); 

mysql_query(conn, sql) returns successful result it's putting 1 in "rec" table in "name" field instead of name, when printf output , use in mysql it's working fine.

update rec set name = (select name pers id = 104 ) id =  43 

is there wrong sprintf? or has added?

i tried static sql command

snprintf(sql,"update rec set name = (select name pers id = 104 ) id = 43");  

and put 1 in rec.name

is due count of record returned sub query? can verify putting condition returns e.g. 2 records name set 2? if reason (though less performing approach) try splitting queries , see if works time.


Comments