GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   very easy SQL question (https://gfy.com/showthread.php?t=429856)

Zester 02-10-2005 01:57 PM

very easy SQL question
 
I need a simply SQL query to get the amount of 'Approved' galleries I have in database, and the amount of 'Pending' galleries I have in database

what do I use?

it should be something like this:

SELECT * count(status='Approved') approved, count(status='Pending') pending
FROM galleries



what do you say?

cfU 02-10-2005 02:05 PM

select status, count(*)
from galleries
where status in ('Approved','Pending')
group by status

Nathan 02-10-2005 02:06 PM

SELECT SUM(IF(status='Approved',1,0)) approved, SUM(IF(status='Pending',1,0)) pending FROM galleries;

Clarion 02-10-2005 02:07 PM

I believe...

SELECT * count(status='Approved') as approved, count(status='Pending') as pending
FROM galleries

...it should work for ya.

calmlikeabomb 02-10-2005 02:20 PM

Quote:

Originally Posted by Zester
I need a simply SQL query to get the amount of 'Approved' galleries I have in database, and the amount of 'Pending' galleries I have in database

what do I use?

it should be something like this:

SELECT * count(status='Approved') approved, count(status='Pending') pending
FROM galleries



what do you say?

Code:

$approvedquery = "SELECT * FROM galleries WHERE status='Approved'";
$approved = @mysql_results($approvedquery);
$numapproved = mysql_num_rows($approved);

There are currently $numapproved approved galleries.

That would be the correct way to do it......


All times are GMT -7. The time now is 10:37 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123