I would like to find out if all the column of the row selected has the equal value. And if all have the same values I would like to perform some action.
id (tableA) id2 (reference tableB) status
-------------------------------------------
1 2 On
2 2 Off
3 3 On
4 3 On
if id2=3 have the same value of status { // perform action here }. How can I check the values of id=3 then perform some action here? I'm using mysql and php.
I don't know if I'm doing it right:
$change = mysql_query("SELECT status from tableA where status = 'On' and id=3 ");
if ($change == 'On')// if all the columns
{ mysql_query(" UPDATE tableB
SET status2 = 'On Going' where id2 =3")or die(mysql_error());
}
Result should be updated in tableB:
id status2
---------------
3 On Going