mysql - How to insert a row to table with another table's row and an variable? -


there 2 table:

a: col1, col2   b: col3, col4 

i want insert row table a, col2 selected table b's col3, col1 variable, how should this?

i'm considered sql:

 insert a(col1, col2) select ?, col3 b col4=? 

, troubled variable.

try this

declare @variable_name int;  set @variable_name= your_value;   insert a(col1, col2) select @variable_name, col3 b col4=[your_condition] 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -