php - mysql query to return true if all status for a particular id field is true -


i have db table more 1 rows same id filed, field status (may 1 or 0). want status 1 if status 1 particular id else 0 if 1 status 0(zero)

you can use mysql's min() function:

  • for particular id:

    select min(status) my_table id = ? 
  • for id:

    select id, min(status) my_table group id 

Comments