| View previous topic :: View next topic |
| Author |
Message |
admin Site Admin
Joined: 21 Jun 2005 Posts: 209
|
Posted: Wed Jul 19, 2006 12:12 am Post subject: Postfix/MySQL -- LIKE in SELECT |
|
|
I have virtual alias maps configured to lookup from a MySQL database:
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
# cat mysql_virtual_alias_maps.cf
user = *******
password = ******************
hosts = ******** ********
dbname = *****
query = SELECT destination FROM aliases WHERE address='%s'
I would like to do something like:
query = SELECT destination FROM aliases WHERE address='%s' AND
somefield NOT LIKE '%value%'
But when I try, I get an error:
postfix/smtpd[12151]: fatal: db_common_parse:
/etc/postfix/mysql_virtual_alias_maps.cf: Invalid query template: SELECT
destination FROM aliases WHERE address='%s' AND destination NOT LIKE '%value%'
I have tried escaping the % signs in the LIKE clause with \, \\ and \\\ but it
doesn't make a difference.
Any ideas how I can accomplish this?
TIA,
Chris
--
Chris Wik
ANU Internet Services
W: http://www.anu.net/
E: chris@anu.net
T: +44 (0)117 9118820 |
|
| Back to top |
|
 |
admin Site Admin
Joined: 21 Jun 2005 Posts: 209
|
Posted: Wed Jul 19, 2006 12:16 am Post subject: |
|
|
$ man mysql_table
...
query The SQL query template used to search the database, where %s is
a substitute for the address Postfix is trying to resolve, e.g.
query = SELECT replacement FROM aliases WHERE mailbox = '%s'
This parameter supports the following '%' expansions:
%% THIS IS REPLACED BY A LITERAL '%' CHARACTER. |
|
| Back to top |
|
 |
|