Qmail Support Forum Forum Index Qmail Support Forum
Qmail Email Server Support Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Postfix/MySQL -- LIKE in SELECT

 
Post new topic   Reply to topic    Qmail Support Forum Forum Index -> Exim
View previous topic :: View next topic  
Author Message
admin
Site Admin


Joined: 21 Jun 2005
Posts: 208

PostPosted: Wed Jul 19, 2006 12:12 am    Post subject: Postfix/MySQL -- LIKE in SELECT Reply with quote

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
View user's profile Send private message Send e-mail
admin
Site Admin


Joined: 21 Jun 2005
Posts: 208

PostPosted: Wed Jul 19, 2006 12:16 am    Post subject: Reply with quote

$ 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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Qmail Support Forum Forum Index -> Exim All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com

For Support - http://forums.BizHat.com

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!