RE: [PHP] Braindead
- From: phpmailing@xxxxxxxxxxxxx ("Chris Haensel")
- Date: Fri, 29 Aug 2008 10:38:12 +0200
-:- -----Original Message-----
-:- From: Thijs Lensselink [mailto:dev@xxxxxxxx]
-:- Sent: Friday, August 29, 2008 10:31 AM
-:- Cc: php-general@xxxxxxxxxxxxx
-:- Subject: Re: [PHP] Braindead
-:-
-:- Chris Haensel wrote:
-:- > Hi guys,
-:- >
-:- > maybe I am too stupid, but I can not see a solution for
-:- this. Have been
-:- > cracking up my brain for the last hours, so I finally
-:- dare to ask.
-:- >
-:- > I have a database table with some columns
-:- >
-:- >
-:- > text1 | text2 | text3 | text4
-:- > ----------------------------------------------
-:- >
-:- >
-:- > Now, for some stats thingy, I am trying to get the COUNT
-:- of distinct entries
-:- > So, i would like to get the count of entries where text2
-:- is foo OR text3 is
-:- > foo
-:- >
-:- > I have 20.863 entries at the moment, and it takes quite
-:- a lot of time
-:- > reading through that stuff.
-:- > I have tried
-:- >
-:- > SELECT COUNT(*) as mycount FROM mytable WHERE text2 =
-:- 'foo' and text3 =
-:- > 'foo'
-:- >
-:- > but I neither get an error nor any output. It just loads
-:- and loads without
-:- > any output...
-:- >
-:- > I am out of ideas :o( Help, anybody? :o))
-:- >
-:- > Chris
-:- >
-:- >
-:- >
-:- >
-:- The amount of records is not that big to slow things down.
-:- Did you use
-:- indexes on your database? And did you try running the query through
-:- commandline or phpMyAdmin?
-:-
-:-
-:- --
-:- PHP General Mailing List (http://www.php.net/)
-:- To unsubscribe, visit: http://www.php.net/unsub.php
-:-
-:-
Hi Thijs,
thanks for the reply. I got mixed up with my tables :o) It's got 178.456
entries :o))
Anyhow, I tried it in a PHP script.
$gq = "SELECT planned_dep_ap, COUNT(*) as apcount FROM flightdb
GROUP BY planned_dep_ap";
$gd = mysql_query($gq) or die(mysql_error());
while($ga = mysql_fetch_assoc($gd)) {
$icao = $ga['planned_dep_ap'];
$apcount = $ga['apcount'];
if($apcount >= 100) {
echo $icao." -> ".$apcount."<br>";
}
}
this should get me the count of all entries and output it. It looks like it
does it now, as I do get an output. It just takes like 25+ seconds to show
me the output :o( Any idea how I can get it faster?
Cheers for your help!
Chris
P.S.: Is there a way to order the output by the apcount value? So I can get
highest numbers first?
.
- Follow-Ups:
- Re: [PHP] Braindead
- From: "Andrew Ballard"
- Re: [PHP] Braindead
- References:
- Re: [PHP] Braindead
- From: Thijs Lensselink
- Re: [PHP] Braindead
- Prev by Date: Re: [PHP] Braindead
- Next by Date: _SERVER['DOCUMENT_ROOT'] not set?
- Previous by thread: Re: [PHP] Braindead
- Next by thread: Re: [PHP] Braindead
- Index(es):
Relevant Pages
|