![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster 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 us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Jul 2003
Posts: 5,344
|
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? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Jan 2003
Posts: 933
|
select status, count(*)
from galleries where status in ('Approved','Pending') group by status |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Industry Role:
Join Date: Jul 2003
Posts: 3,108
|
SELECT SUM(IF(status='Approved',1,0)) approved, SUM(IF(status='Pending',1,0)) pending FROM galleries;
__________________
"Think about it a little more and you'll agree with me, because you're smart and I'm right." - Charlie Munger |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Join Date: Jan 2005
Location: Ontario, OR
Posts: 148
|
I believe...
SELECT * count(status='Approved') as approved, count(status='Pending') as pending FROM galleries ...it should work for ya.
__________________
Structure Northwest :: the cure for the common code :: AIM: Asatruel | Yahoo!: Asatruel | ICQ: 111-638-053 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 | |
Confirmed User
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
|
Quote:
Code:
$approvedquery = "SELECT * FROM galleries WHERE status='Approved'"; $approved = @mysql_results($approvedquery); $numapproved = mysql_num_rows($approved); There are currently $numapproved approved galleries.
__________________
subarus. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |