I need to add some records to a table, but only those that match a certain linked table.
There are three tables are as follows:
extension_prefs (extension_id, value, parameter)
extension (id, client_id)
client (id, parent_client_id)
These will link as follows:
extension_prefs.extension_id = extension.id AND extension.client_id = client.id
I need to insert 4 records into extension_prefs for every extension belonging to a client with a specific parent_client_id. I have no idea of the syntax to achieve this although I have the feeling its quite straightforward.
EDIT: Yes I messed this up, these records need to be UPDATED not INSERTED.
Thanks very much
George
You can call the following query for each of the preferences and it will be saved for all the necessary extensions.
Updated:
The following query inserts a new row for the preference or if it exists then updates the existing one.
This assumes that the extension_prefs table has a unique constraint on the extension_id and parameter columns.