Skip to main content
added 312 characters in body
Source Link
Axel
  • 14.2k
  • 6
  • 55
  • 80

Try this:

SELECT COUNT(*) AS currentstate FROM mytable WHERE mid = 100 AND currentstate='Yes'; 

EDIT: "Now If i put mt.currentstate = 'Yes' inside WHERE clause, it will filter all the rows where mt.currentstate = 'Yes', but I need other column values from the rows mt.currentstate = 'No'..What I'm gonna do?"

SELECT currentstate, COUNT(*) AS c FROM mytable WHERE mid = 100 GROUP BY currentstate; 

Try this:

SELECT COUNT(*) AS currentstate FROM mytable WHERE mid = 100 AND currentstate='Yes'; 

Try this:

SELECT COUNT(*) AS currentstate FROM mytable WHERE mid = 100 AND currentstate='Yes'; 

EDIT: "Now If i put mt.currentstate = 'Yes' inside WHERE clause, it will filter all the rows where mt.currentstate = 'Yes', but I need other column values from the rows mt.currentstate = 'No'..What I'm gonna do?"

SELECT currentstate, COUNT(*) AS c FROM mytable WHERE mid = 100 GROUP BY currentstate; 
Source Link
Axel
  • 14.2k
  • 6
  • 55
  • 80

Try this:

SELECT COUNT(*) AS currentstate FROM mytable WHERE mid = 100 AND currentstate='Yes';