Forum Moderators: open

Message Too Old, No Replies

sql query

         

tonynoriega

2:52 pm on Aug 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need to group the query below for a specific community. I have the "Community" field in my sql table, and the communities are either community A or community B, how can i add to this query to only group by community A?

i tried adding "AND WHERE community="community A" at the end, but gave me an error.

$sql = 'SELECT COUNT(last_visit) AS last_visit, (SELECT COUNT(*) FROM registration_table WHERE DATE_SUB(CURDATE(),INTERVAL 6 DAY) <= entry_time) AS totalcount FROM registration_table WHERE DATE_SUB(CURDATE(),INTERVAL 6 DAY) <= last_visit';

tonynoriega

3:55 pm on Aug 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



just thought id share how i figured it out...

$sql = 'SELECT COUNT(community) AS comm_count, (SELECT COUNT(*) FROM registration_table WHERE DATE_SUB(CURDATE(),INTERVAL 6 DAY) <= entry_time AND community=\'Sonata\') AS totalcount, (SELECT COUNT(last_visit) FROM registration_table WHERE DATE_SUB(CURDATE(),INTERVAL 6 DAY) <= last_visit AND community=\'Sonata\') AS last_visit FROM registration_table WHERE DATE_SUB(CURDATE(),INTERVAL 6 DAY) <= entry_time AND community=\'Sonata\'';

i had to add "AND community=\'Sonata\'" to each statement.