I want to update a table depending on a variable eg:
$number = 3;
UPDATE Table1 m
SET m.col1 = 1
WHERE m.id IN (SELECT id From Table2 where other_id = m.other_id)
ELSE
SET all remaining to 0
UPDATE Table1 m SET m.col1 = 0
So all I want is if $number is 0 all records will be 0 if $number > 0 then that quantity of rows needs to be set 1 in Table1 Note: records need to be last records DESC id limit $number
Edit: To better communities what my need is, this how I would successfully accomplish it with php and sql but I will need to run 2 separate queries.
See pic
As you see I'm using two separate queries I was wondering if it could be done with sql only.