Jump to content

Count problem


inbowns

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/252327-count-problem/
Share on other sites

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' ";

Link to comment
https://forums.phpfreaks.com/topic/252327-count-problem/#findComment-1293604
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/252327-count-problem/#findComment-1293619
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.