[PHP] Compare 2 resultsets of db-query
Hi, I've two queries on the same table. They have the following structure: Query1: SELECT FIELD1, COUNT(FIELD2) AS TOTAL from TABLE GROUP BY FIELD1 Query2: SELECT FIELD1, COUNT(FIELD2) AS SUB from TABLE WHERE FIELD2=1 GROUP BY FIELD1 Now I want to print a table that prints the values of FIELD1, TOTAL and SUB. Query 1 returns more rows as query 2. Field1 is the same in both queries so I should be able to 'link' the results of both queries together. How do I do this?? Thanks! Danny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Compare 2 resultsets of db-query
Analysis & Solutions wrote: > Hey Danny: > > On Mon, Jun 10, 2002 at 10:09:12PM +0200, Danny Kruitbosch wrote: > >>Query1: SELECT FIELD1, COUNT(FIELD2) AS TOTAL from TABLE GROUP BY FIELD1 >>Query2: SELECT FIELD1, COUNT(FIELD2) AS SUB from TABLE WHERE FIELD2=1 >>GROUP BY FIELD1 >> >>Now I want to print a table that prints the values of FIELD1, TOTAL and >> SUB. >> >>Query 1 returns more rows as query 2. Field1 is the same in both queries >>so I should be able to 'link' the results of both queries together. >> > > I'm wondering exactly what you're trying to do. It may be possible to do > in one well crafted query. Why limit the second query only to items where > Field2 = 1? What's in FIELD1 and FIELD2? > > Also, I assume you want each row of your HTML table to have the FIELD1, > TOTAL and SUB fields in them, right? > > --Dan > > FIELD 1 contains IP address pool names (not unique), field2 the status (0 free, 1 leased). So what I try to do is get an overview of the total number of IP adresses in a pool and the number of leased addresses. There's a fourth field that contains the actual address. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Compare 2 resultsets of db-query
Analysis & Solutions wrote: > On Wed, Jun 12, 2002 at 04:54:30PM +0200, Danny Kruitbosch wrote: > >>Analysis & Solutions wrote: >> >>>Hey Danny: >>> >>>On Mon, Jun 10, 2002 at 10:09:12PM +0200, Danny Kruitbosch wrote: >>> >>> >>>>Query1: SELECT FIELD1, COUNT(FIELD2) AS TOTAL from TABLE GROUP BY FIELD1 >>>>Query2: SELECT FIELD1, COUNT(FIELD2) AS SUB from TABLE WHERE FIELD2=1 >>>>GROUP BY FIELD1 >>>> >>FIELD 1 contains IP address pool names (not unique), field2 the status >>(0 free, 1 leased). So what I try to do is get an overview of the total >>number of IP adresses in a pool and the number of leased addresses. >>There's a fourth field that contains the actual address. >> > > 0 and 1 in FIELD2? That makes this a piece of cake! All you need is one > query. In Query1, do a SUM(FIELD2) rather than COUNT(FIELD2). Forget > about Query2. > > --Dan > > Thanks! Sometimes the obvious is the last thing you think about Danny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] md5 php vs. md5 perl
Hi, I'm trying to rewrite a perl finction to php. The function uses Digest::MD5. PHP md5() returns a 32 char hex number. The perl Digest::MD5 function returns a 16 char (ascii??) string. Can I also get this from PHP? If so how do I do that? My ultimate goal is to have compatible PHP/Perl functions. Thanks! Danny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] translate perl unpack to php equivalent
Hi, How would I translate this perl unpack statement to the php equiv. my ($salt, $xor) = unpack('a2 a*', $something) Thanks! Danny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php