![]() |
| |||
| Hi! I wonder if anyone can tell me if there is anything I can do to make this set of queries a lot more efficient. Right now I have this code that lists statistics as below: Guestbook Statistics Comments: 42 records 2003-06: 6 2003-07: 4 2003-08: 1 2003-09: 4 2003-10: 1 2003-11: 2 2003-12: 1 2003: 19 -------------------- 2004-01: 1 2004-02: 1 2004-03: 3 2004-04: 1 2004-05: 1 2004-08: 3 2004-10: 1 2004-11: 1 2004: 12 -------------------- 2005-01: 1 2005-03: 1 2005-06: 1 2005-07: 3 2005-08: 2 2005: 8 -------------------- 2006-05: 3 2006: 3 -------------------- And the code that produced this is as follows: "SELECT DISTINCT(SUBSTRING(entry, 1, 4)) AS years FROM guestbook ORDER BY years ASC" "SELECT COUNT(entry) AS total FROM guestbook WHERE entry LIKE '". $year .. "%'"; "SELECT DISTINCT(SUBSTRING(entry, 1, 7)) AS months FROM guestbook WHERE entry LIKE '" . $year . "%' ORDER BY months ASC" "SELECT COUNT(entry) AS days FROM guestbook WHERE entry LIKE '". $months . "%'" I'd welcome any comments that might make this work a lot better. I think what I've written is really crap and the network gets a bit overloaded when I execute these queries. Thanks for any advice offered. -- http://www.munted.org.uk Take a nap, it saves lives. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |