RE: [PHP-DB] mysql statement: two tables, two comparisons

From: Date: Thu, 06 Mar 2003 15:44:58 +0000
Subject: RE: [PHP-DB] mysql statement: two tables, two comparisons
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-26123@lists.php.net to get a copy of this message
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 steiner277@charter.net -----Original Message----- From: Jason End [mailto:bensnephew@yahoo.com] Sent: Thursday, March 06, 2003 8:52 AM To: php-db@lists.php.net 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

« previous php.db (#26123) next »