If I could figure out how to structure the query, I would be happy to do so. The problem is that I am working with 3 different tables for this. Additionally, I ran into a brick wall when trying to structure the query to remove/eliminate the entries in the exclusion table. The exclusion table has 13 entries currently, and the last thing I tried with the query was outputting 13 entries of every system. Here is the query that was yielding this... #$query = "SELECT AllMid_Data.CPU_Hostname FROM AllMid_Data, exclusion # WHERE AllMid_Data.CPU_IN_SVC = \"Y\" # AND AllMid_Data.CPU_DNS = \"sbcld.sbc.com\" # AND AllMid_Data.CPU_Hostname != exclusion.hostname # ORDER BY CPU_Hostname ASC"; Scott Nipp Phone: (214) 858-1289 E-mail: sn4265@xxxxxxx Web: http:\\ldsa.sbcld.sbc.com -----Original Message----- From: Bastien Koert [mailto:bastien_k@xxxxxxxxxxx] Sent: Monday, March 28, 2005 11:13 AM To: NIPP, SCOTT V (SBCSI); php-db@xxxxxxxxxxxxx Subject: RE: RE: Further MySQL query problems... why wouldn't you just run a query to return only the elements that you want? Bastien >From: "NIPP, SCOTT V (SBCSI)" <sn4265@xxxxxxx> >To: <php-db@xxxxxxxxxxxxx> >Subject: RE: Further MySQL query problems... >Date: Mon, 28 Mar 2005 10:49:24 -0600 > > Oops... Correction to the last line of the script. > <?php } while ($blah = mysql_fetch_array($exclude_results)); ?> > > Should be... > <?php } while ($blah = array_shift($temp)); ?> >Scott Nipp >Phone: (214) 858-1289 >E-mail: sn4265@xxxxxxx >Web: http:\\ldsa.sbcld.sbc.com > > > > -----Original Message----- > > From: NIPP, SCOTT V (SBCSI) > > Sent: Monday, March 28, 2005 10:47 AM > > To: 'php-db@xxxxxxxxxxxxx' > > Subject: Further MySQL query problems... > > > > I am having trouble in the following code. Basically, I want to > > query two separate database tables and then generate an array from > > these two queries. The first query will return a list of ALL systems. > > The second query will return a list of systems that should be > > excluded. The problem is that this is getting me nowhere. Here is > > the pertinent code... > > > > $query = "SELECT CPU_Hostname FROM AllMid_Data > > WHERE CPU_IN_SVC = \"Y\" > > AND CPU_DNS = \"sbcld.sbc.com\" > > ORDER BY CPU_Hostname ASC"; > > $results = mysql_query($query, $Prod) or die(mysql_error()); > > $system = mysql_fetch_array($results, MYSQL_NUM); > > $exclude_query = "SELECT hostname FROM exclusion"; > > $exclude_results = mysql_query($exclude_query, $Prod); > > $exclude = mysql_fetch_array($exclude_results, MYSQL_NUM); > > $temp = array_diff($system, $exclude); > > <?php do { > > $sys = $blah[0]; > > echo "<tr>"; ?> > > <?php echo $sys; ?> > > <?php echo "</tr>"; } ?> > > <?php } while ($blah = mysql_fetch_array($exclude_results)); ?> > > > > I have cut out a lot of extraneous stuff that I don't think is > > pertinent. Please let me know if you see something causing my > > problems. The first query table has about 900 entries and the query > > returns about 90 hostnames. The exclude table query has only 13 > > hostnames and obviously returns all. I am looking for a way to > > display the approximately 77 entries that are NOT in the exclude > > table. Thanks again. > > > > Scott Nipp > > Phone: (214) 858-1289 > > E-mail: sn4265@xxxxxxx > > Web: http:\\ldsa.sbcld.sbc.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