'Insert into conditional statement

I am trying to insert data into a table, on the condition that the reference I have, will match primary to secondary key in another table, and return ANOTHER column (id) from the second table to the first one.

$sku_data = "some data"; (data) 
$client_ref = "baccd3c7057595380688e40d94b35ba1"; (condition)

I have a $client_ref and $sku_data in PHP, I want to insert this into table sku, but the client_id in table sku should return column id from table client that matches row to column client_ref.

Please see the attachment. picture



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source