Hello,
Exim 4 integrated with MySQL 4.
I have four tables:
CREATE TABLE users (
uid bigint(10) unsigned DEFAULT '' NOT NULL auto_increment,
listemail varchar(200) DEFAULT '' NOT NULL ,
PRIMARY KEY (uid),
);
CREATE TABLE groups (
gid int(11) DEFAULT '' NOT NULL auto_increment,
listemail longtext ,
UNIQUE gid (gid),
);
CREATE TABLE mailalias (
mid int(11) DEFAULT '' NOT NULL auto_increment,
listemail longtext ,
UNIQUE mid (mid)
);
CREATE TABLE mailgroups (
id int(10) DEFAULT '' NOT NULL auto_increment,
uid int(11) ,
gid int(11) ,
mid int(11) DEFAULT '0' NOT NULL ,
PRIMARY KEY (id)
);
mailgroups contains relations between mailalias, users and groups:
select * from mailgroups;
+----+------+------+-----+
| id | uid | gid | mid |
+----+------+------+-----+
| 1 | NULL | 3 | 17 |
| 2 | NULL | 32 | 17 |
| 3 | 61 | NULL | 17 |
| 4 | 72 | NULL | 17 |
+----+------+------+-----+
What I need to do is:
Given mailalias.liste mail, get users.listemail and groups.listemai l
that are part of mailalias.liste mail. Ie: if mid is 17, find gid 3 and
32, uid 61 and 72. I found in the manual a way to do it with two
queries:
SELECT users.listemail FROM users,mailgroup s,mailalias WHERE
mailgroups.uid = users.uid AND mailgroups.mid = mailalias.mid AND
mailalias.liste mail
='$LISTEMAIL'
and then the same query with groups instead of users.
But because this is run within Exim, I need this in one query.
Basically, given an email address, I need to find the users and groups
that are associated with that address.
Any help would be appreciated.
Thanks
Kimo R. 3 3029
Kimo R. wrote: SELECT users.listemail FROM users,mailgroup s,mailalias WHERE mailgroups.uid = users.uid AND mailgroups.mid = mailalias.mid AND mailalias.liste mail ='$LISTEMAIL'
and then the same query with groups instead of users.
But because this is run within Exim, I need this in one query. Basically, given an email address, I need to find the users and groups that are associated with that address.
I tried this on my test database and it seems to do what you describe:
select coalesce(u.list email, g.listemail)
from mailalias a inner join mailgroups m on (a.mid = m.mid)
left outer join users u on (m.uid = u.uid)
left outer join groups g on (m.gid = g.gid)
where a.listemail = '$LISTEMAIL'
Regards,
Bill K.
Bill Karwin <bi**@karwin.co m> wrote in message news:<cf******* **@enews1.newsg uy.com>... Kimo R. wrote: But because this is run within Exim, I need this in one query. Basically, given an email address, I need to find the users and groups that are associated with that address.
select coalesce(u.list email, g.listemail) from mailalias a inner join mailgroups m on (a.mid = m.mid) left outer join users u on (m.uid = u.uid) left outer join groups g on (m.gid = g.gid) where a.listemail = '$LISTEMAIL'
Perfect. Thank you very much.
Kimo R.
Just combine these two queries with UNION ALL:
SELECT users.listemail FROM users,mailgroup s,mailalias
WHERE
mailgroups.uid = users.uid
AND mailgroups.mid = mailalias.mid
AND mailalias.liste mail='$LISTEMAI L'
UNION ALL
SELECT groups.listemai l FROM groups,mailgrou ps,mailalias
WHERE
mailgroups.gid = groups.gid
AND mailgroups.mid = mailalias.mid
AND mailalias.liste mail='$LISTEMAI L'
"Kimo R." <ki*****@hotmai l.com> wrote in message
news:e5******** *************** ***@posting.goo gle.com... SELECT users.listemail FROM users,mailgroup s,mailalias WHERE mailgroups.uid = users.uid AND mailgroups.mid = mailalias.mid AND mailalias.liste mail ='$LISTEMAIL'
and then the same query with groups instead of users.
But because this is run within Exim, I need this in one query. Basically, given an email address, I need to find the users and groups that are associated with that address. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kimo R. |
last post by:
Hello,
Exim 4 integrated with MySQL 4.
I have four tables:
CREATE TABLE users (
uid bigint(10) unsigned DEFAULT '' NOT NULL auto_increment,
listemail varchar(200) DEFAULT '' NOT NULL ,
PRIMARY KEY (uid),
|
by: jqq |
last post by:
SQL2K on W2Kserver
I need some help revamping a rather complicated query. I've given the
table and existing query information below. (FYI, changing the
database structure is right out.)
The current query lists addresses with two particular types
('MN30D843J2', 'SC93JDL39D'). I need to change this to (1) check each
contact for address...
|
by: John young |
last post by:
I have been looking for an answer to a problem and have found this
group and hope you can assist .
I have been re doing a data base I have made for a car club I am with
and have been trying to make a query that selects from a table as
desribed below ..
I have a table (Volunteer) that has a member field (memnumber)
and a number of fields ...
|
by: Robert |
last post by:
I am trying to create a db for service providers by county. I'm relatively
new to db programming, but I have done quite a bit of programming ranging
from the old basic days up to doing some programming in the HotDocs
software. I've kind of accomplished my goal in access, but I'm not quite
there yet and figure I've really screwed something...
|
by: L. R. Du Broff |
last post by:
I own a small business. Need to track a few hundred pieces of rental
equipment that can be in any of a few dozen locations. I'm an old-time C
language programmer (UNIX environment). If the only tool you know how to
use is a hammer, every problem tends to look like a nail. That said, I
could solve my problem in C, but it's not the right...
| |
by: mkjets |
last post by:
I have worked for hours on trying to find a solution and have not
figured it out. I am working in Access 2003. I need to create a query
that takes values from 1 table and displays them in multiple fields. I
don't have the option of changing the structure of the existing tables
because I am importing them from a separate data source on a...
|
by: dancole42 |
last post by:
So I have an invoicing database based on two main forms: Orders and
OrderLines. Orders has fields like:
OrderID
BillingMethod
OrderDate
CreditCard
CCExp
OrdSubTotal
ShippingCharge
|
by: epiphyte |
last post by:
Let's say I have a table with a list of young folk (table1). This table is related to a table that lists all their booty calls (table2). A third table lists their booty calls' booty calls (table3). For the purposes of this example the tables are set up as a one to many relationship.
The young folks in table1 want to lower their risk of...
|
by: jcf378 |
last post by:
Hi all--
Does anyone have any insight as to how I might create a search form
that allows a user to select criteria based on any related table in
the whole database. The search form I have now only allows me to
filter based on variables in a single table. I would like to have a
search form where I can select multiple variables (from various...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |