SQL / PHP where子句根据行id更改

I wish to select all rows depending on the where value, which changes with each row. The best way to explain it would be like this...

SELECT * FROM `table` WHERE `time` < $array[ ROW ID ][ time ]

Hence, the value of the where clause will change depending on the row itself

You could use a sub query:

SELECT * FROM `table` WHERE `time` < (
  SELECT `time` FROM `table` WHERE `id` = ROW_ID
);

The sub query selects time from the row with id ROW_ID and after that the main query compares the result to time properties of the other records in the table.

You play around with the query at SQLFiddle


The question was a little bit hard to get.. I think now (after discussion) this is what you want:

$sql = 'SELECT * FROM `table` WHERE `time` < ' . $array['ROW_ID']['time'];