Sample Header Ad - 728x90

execute insert and select statements consecutively after a case statement

0 votes
1 answer
78 views
I want to execute insert and select statements once a condition is met on mysql, not sure how to do it. ##declare variables SET @fvar = 'sometxt', @svar = 'sometxtagain'; SELECT @start := 1, @finish := 10; select count(somecolumnID) as columnname, case when count(somecolumnID) = '0' then ( ##insert statement here which will automatically generate a unique id, use @fvar here ##select statement here to get the unique id (@tvar) from first insert statement ##insert statement here which will automatically generate a unique 2nd_id (@fovar), use @svar and @tvar here ##select statement here to get the unique 2nd_id from second insert statement, use @fovar here ) else 'record exist. nothing to do here' end as output from table_name where id = 'user_input';
Asked by hellyeah99 (1 rep)
Jan 25, 2023, 11:05 PM
Last activity: Jan 26, 2023, 02:08 AM