I have a MySQL problem I can not get to solve. I have a mysql to manage a virtual user dovecot installation, that uses two tables (one for the aliases, another for the domains).
The table aliases has these fields: domain_id(INT), source(VARCHAR), destination(VARCHAR), whereas table domains has only two fields: id (INT AUTO INC) and name (VARCHAR).
Although I'm able to select aliases that belong to a given domain by issuing:
SELECT valias.* FROM aliases AS valias
JOIN domains AS vdomains ON valias.domain_id=vdomains.id
WHERE vdomains.name = "domain_name";
I can not get to work to insert a new alias, specifing the domain name. something like this:
INSERT INTO valias(domain_id, source, destination)
VALUES (id, 'canto', 'george')
SELECT id FROM aliases
JOIN domains AS vdomains ON aliases.domain_id=vdomains.id
WHERE vdomains.name = "domain_name";
Does somebody know how to solve this problem?