I have a DB with table1 (id, name_id, value) and table2 (id, name, other)
then I have some data
$name = 'a name';
$value = 'a value';
I want to use the value $name as table2.name to get table2.id and insert it into table1 as table1.name_id but then I also want to insert $value into table1.
when doing a SELECT I could use JOIN, but the only thing I've found for INSERT is to use a SELECT query instead of VALUES
However, I want to use a value from table2 (id) as well as insert $value but the SELECT method seems to only copy data from one table (table2) to another
Edit: pseudo SQL
<pre>INSERT INTO `table1` (`name_id`, `value`)
VALUES ((`table2`.`id` WHERE `table2`.`name` = $name), $value)</pre>