0

i am trying to add a select in an insert statement but one of my parameters is not part of the select and i d'ont know how to handle this. would you mind helping me please, thanks

what i want to achieve is :

  • inserting data into my table installs_workflows(install_id,action_id,order)
  • the first col (install_id) is fixed (already defined value i have in my code)
  • i want to gather the data for the two last columns in another select

i wanted to do something like this but i'm not sure it will work

insert into installs_workflows(install_id,action_id,order) values("myIDhere", (select action,order from installs_actions where ostype=0)) 

let me know if you don't understand what i'm trying to achieve, thanks.

(in fact, for each result found in the SELECT statement, i want to insert them in the table installs_workflows with a specific install_id (that is the same)

thanks again

ps : or can i add a dmmy value in the select maybe ? this way i could do something like :

insert into installs_workflows(install_id,action_id,order) select "MyID",action,order from installs_actions where ostype=0 
2
  • 1
    You can still use it in the select, something like this: insert into table (col1, col2) select 'myidhere', action from ... Commented Sep 11, 2019 at 13:33
  • Possible duplicate of Insert into ... values ( SELECT ... FROM ... ) Commented Sep 11, 2019 at 13:35

1 Answer 1

1

Use a SELECT directly as

insert into installs_workflows(install_id,action_id,order) select 'myIDhere', action,order from installs_actions where ostype = 0; 
Sign up to request clarification or add additional context in comments.

1 Comment

thanks, just noticed that i could specify any value in the select on purpose, will mark the answer as the right one when possible

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.