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

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

SQL Server - MyCTE query based on 24 hour period (next day) -