J,

Try this (it assumes that the softid you want to search for is in the
variable $softid):

$sql = "SELECT Expert.*
        FROM Expert
        LEFT JOIN Apliexpert ON Expert.id = Apliexpert.exptid
        WHERE Apliexpert.softid = '$softid'
        ORDER BY Expert.Name";

----------------------
Beverly Steiner
[EMAIL PROTECTED]



-----Original Message-----
From: Jason End [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 06, 2003 8:52 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] mysql statement: two tables, two comparisons


I'm looking for a mysql select statement that does the
following:

- Check if the value of each expert.id on the table
experts matches a value expt.id in the table
apliexpert.
- For those values where this is true check whether
the softID value for that row matches the variable
$softId.
- return the names that are left after those 2 filters

So for tables:

Expert
id    Name
1    Peter
2    Paul
3    Mary
4    Frank

Apliexpert
exptid  softid
1           3
2           5
2           8
3           9
3           8

1. If the softID is 2, the select should return:
peter, paul, mary and frank (frank will always be
returned no matter what, because he isn't in
apliexpert)
2. If the softID is 3, the select should return: paul,
mary and frank
3. If the softID is 8, the select should return: peter
and frank
4. If the softID is 9, the select should return:
peter, paul and frank

J

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to