![]() |
Simplying a few MySQL Queries - Help Needed
I have the following queries that, if possible, I need to simplify. I'd like to knock this down to as few queries as possible as I will need to call additional (probably 2 other items) from the same row.
I am just looking to get the number of rows matching each set, though I'd rather knock 4 queries down to 1-2 if there is another way to do so. PHP Code:
|
Try the below, maybe it will work. I need to start coding php more, and stop with vb.net. I'm starting to forget stuff!
PHP Code:
|
Quote:
As I need it to report the total for the entire table, the above will not work. I have 8 entries in the table and the above reports a blank for active and 1 for pending (when all 8 are pending). |
Quote:
PHP Code:
|
I think the logic may be backwards in that, totalactive should be when ispending = 0.
Try ; PHP Code:
|
PHP Code:
|
Can you explain this bit?
[sql]IF(ispending = 1, 1, 0)) [/sql] I've never seen this before... |
if the value of ispending is '1', it will result in a value of 1, otherwise 0 (zero), if you then sum it, you will count 1 for each row that have ispending = 1.
By testing ispending = 0, you can reverse the count. |
Quote:
|
That depends totally on the query. Since this one are simple embedded functions, not used in where/order by/join conditions, i would say the query is much faster then doing it in php.
|
All times are GMT. The time now is 04:13 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|