inbowns Posted December 2, 2011 Share Posted December 2, 2011 I have a database which I was successfully able to pull data from and utilize but now I have a problem. I need to get data from a column that I have Yes or No in and I'm not sure to go about retriving this data. I basically need to count all the data that is listed as Yes. Any help is greatly appreciated. Quote Link to comment Share on other sites More sharing options...
premiso Posted December 2, 2011 Share Posted December 2, 2011 SELECT count(*) as yes_count FROM table_name WHERE column_yes_no = 'Yes' Should do it. Quote Link to comment Share on other sites More sharing options...
inbowns Posted December 2, 2011 Author Share Posted December 2, 2011 SELECT count(*) as yes_count FROM table_name WHERE column_yes_no = 'Yes' Should do it. Thank you for your reply I tired that and it works but I have other stuff that goes in the statement.Do you think you can help me clear that up also? $sql ="SELECT effdate, carrier, COUNT(carrier), SUM(employees), COUNT(employees),COUNT(migrate) FROM info WHERE effdate BETWEEN '$date_search_1' AND '$date_search_1' GROUP BY carrier" AND migrate = 'Yes' "; Quote Link to comment Share on other sites More sharing options...
premiso Posted December 2, 2011 Share Posted December 2, 2011 Your syntax is invalid... $sql ="SELECT effdate, carrier, COUNT(carrier), SUM(employees), COUNT(employees),COUNT(migrate) FROM info WHERE effdate BETWEEN '$date_search_1' AND '$date_search_1' AND migrate = 'Yes' GROUP BY carrier "; Quote Link to comment Share on other sites More sharing options...
inbowns Posted December 2, 2011 Author Share Posted December 2, 2011 Your syntax is invalid... $sql ="SELECT effdate, carrier, COUNT(carrier), SUM(employees), COUNT(employees),COUNT(migrate) FROM info WHERE effdate BETWEEN '$date_search_1' AND '$date_search_1' AND migrate = 'Yes' GROUP BY carrier "; Yes I understand because it doesn't run am I using too many AND's Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted December 2, 2011 Share Posted December 2, 2011 Look at the BETWEEN parameters. You're using the same value for both of them. It may as well read 'BETWEEN 1 AND 1' . . . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.