Use an insert ... select
query, and put the known values in the select
:
insert into table1
select 'A string', 5, idTable2
from table2
where ...
More Related Contents:
- MySQL error 1241: Operand should contain 1 column(s)
- Recreating a query using INNER JOIN? [duplicate]
- What is better subquery vs literal on IN clause in mysql
- SQL query return data from multiple tables
- quick selection of a random row from a large table in mysql
- How to do a batch insert in MySQL
- MySQL SELECT only not null values
- Ordering by specific field value first
- SQL – IF EXISTS UPDATE ELSE INSERT INTO
- SELECT / GROUP BY – segments of time (10 seconds, 30 seconds, etc)
- How to copy a row and insert in same table with a autoincrement field in MySQL?
- Checking multiple columns for one value
- MySQL Error 1264: out of range value for column
- How do I get the ID of multiple inserted rows in MySQL?
- How to insert data to MySQL with auto-incremented column(field)?
- MySQL #1093 – You can’t specify target table ‘giveaways’ for update in FROM clause
- How to select one row randomly taking into account a weight?
- quick selection of a random row from a large table in mysql
- Compare only day and month with date field in mysql
- SELECT query return 1 row from each group
- What are practical differences between `REPLACE` and `INSERT … ON DUPLICATE KEY UPDATE` in MySQL?
- MySQL INNER JOIN select only one row from second table
- MySQL Select Query – Get only first 10 characters of a value
- MySQL – insert data from another table merged with constants
- Insert data into table with result from another select query
- How to SELECT by MAX(date)?
- MySQL optimizing INSERT speed being slowed down because of indices
- MySQL: Insert datetime into other datetime field
- “Unknown column in ‘field list'”, but column does exist
- Insert and set value with max()+1 problems