![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| Database Database problems or need to ask a question? maybe something to do with sql injections or a database software question. Database topics cover MySQL, PostgreSQL, Oracle, SQL Server or anything else related to databases. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| 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. | |||
| Featured Websites | ||||
|
![]() |
| Tags: optimising, queries |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 2 Queries in 1 statement? | Good Man | Database | 2 | 07-01-2007 6:58 PM |
| Car stereo queries. | blah | Car audio | 3 | 06-18-2007 11:42 AM |
| Same result with differents handler queries | PEx | Database | 0 | 05-31-2007 8:48 PM |
| Correcting queries | James Walker | Database | 0 | 05-31-2007 8:37 PM |
| Looking for any handy SQL queries | Whatcha | Database | 10 | 07-10-2006 6:59 AM |
| Featured Websites | ||||
|