The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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:
|
#2
|
|||
|
|||
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:
|
#3
|
|||
|
|||
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). |
#4
|
|||
|
|||
Quote:
PHP Code:
|
#5
|
||||
|
||||
I think the logic may be backwards in that, totalactive should be when ispending = 0.
Try ; PHP Code:
|
#6
|
|||
|
|||
PHP Code:
|
#7
|
|||
|
|||
Can you explain this bit?
[sql]IF(ispending = 1, 1, 0)) [/sql] I've never seen this before... |
#8
|
|||
|
|||
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. |
#9
|
||||
|
||||
Quote:
|
#10
|
|||
|
|||
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.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|