I need to add minutes coming from an integer column with a timestamp to compare to another column.
Here\'s an example:
SELECT t1.id_liame, t1.id_ta
You can write your query like this:
SELECT
t1.id_liame,
t1.id_table,
t1.periodicidade,
t3.data_extracao,
CASE
WHEN(NOW() < (t3.data_extracao + (INTERVAL '1 min' * t1.periodicidade)))
THEN 'yes' ELSE 'no'
END
FROM table1 AS t1
LEFT JOIN liame_has_extracao AS t2 USING(id_liame)
LEFT JOIN extracao AS t3 USING(id_extracao)
As you can see, you can multiply intervals with integers so with INTERVAL '1 minute'
you define your base unit and multiply your actual time interval.
Hope that helps