![]() |
|
|
Thread Tools |
|
#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.
Is there an alternative, of will I be stuck making 4 seperate calls? No members have liked this post.
|
||||
|
#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!
No members have liked this post.
Last edited by Danny.VBT : 26 Oct 2005 at 04:59. |
||||
|
#3
|
||||
|
||||
|
Originally Posted by Danny.VBT
Thanks for the reply, however, I need them both to be showing at the same time and not alternating.
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). No members have liked this post.
|
||||
|
#4
|
||||
|
||||
|
Originally Posted by CommuneZoom
Try it without the Count clause. So...
No members have liked this post.
|
||||
|
#5
|
||||
|
||||
|
I think the logic may be backwards in that, totalactive should be when ispending = 0.
Try ;
__________________
Cable Forum - DigiGuide Please Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum. Senior vBulletin Developer : Please do not PM me about custom work - I work for Internet brands and no longer have the time to undertake any. No members have liked this post.
|
||||
|
#6
|
|||
|
|||
|
__________________
Marco van Herwaarden Ex vBulletin.org Coordinator No members have liked this post.
|
|
#7
|
||||
|
||||
|
Can you explain this bit?
I've never seen this before... No members have liked this post.
|
||||
|
#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.
__________________
Marco van Herwaarden Ex vBulletin.org Coordinator No members have liked this post.
|
|
#9
|
||||
|
||||
|
Originally Posted by MarcoH64
Interesting question, is it quicker to use a more complicated SQL query, or a simpler query and a bit of PHP.
__________________
Cable Forum - DigiGuide Please Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum. Senior vBulletin Developer : Please do not PM me about custom work - I work for Internet brands and no longer have the time to undertake any. No members have liked this post.
|
||||
|
#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.
__________________
Marco van Herwaarden Ex vBulletin.org Coordinator No members have liked this post.
|
|
#11
|
||||
|
||||
|
Originally Posted by MarcoH64
Thanks Marco
![]() No members have liked this post.
|
|
#12
|
||||
|
||||
|
can IF be used within the parameters of where?
__________________
My Site:Animation Talk My Hacks:Vb3 Affiliate Version 1:vB Affiliates v.2:vB Journal 1.0.0:Quick Attachment Approval System: UnBannable Ips:Text Message on PM:Selected Files Not Closed:New Thread/Post Image Verification for Guests: vB Stocks 1.0.0 This means this hack won an award. No members have liked this post.
|
|
#13
|
|||
|
|||
|
That wouldn't make much sense i think, the where clause is already 1 big if-statement, but i never tried.
more info: http://dev.mysql.com/doc/refman/5.0/...functions.html
__________________
Marco van Herwaarden Ex vBulletin.org Coordinator No members have liked this post.
|
|
#14
|
||||
|
||||
|
/me clicks link
There's so much stuff I haven't even learned yet, Ah! Thanks again Marco. ![]() No members have liked this post.
|
|
#15
|
||||
|
||||
|
i was asking because of this:
http://www.vbulletin.org/forum/showthread.php?t=94088
__________________
My Site:Animation Talk My Hacks:Vb3 Affiliate Version 1:vB Affiliates v.2:vB Journal 1.0.0:Quick Attachment Approval System: UnBannable Ips:Text Message on PM:Selected Files Not Closed:New Thread/Post Image Verification for Guests: vB Stocks 1.0.0 This means this hack won an award. No members have liked this post.
|
![]() |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
| Thread Tools | |
|
|
| New To Site? | Need Help? |
All times are GMT. The time now is 21:05.



