This is a followup to a another question, but I think warrants its own question:
Can I use a field as the 'unit' parameter in TIMESTAMPDIFF()
?
For example, here's a snippet:
SELECT foo FROM table t LEFT JOIN frequencies f USING (frequency_id)
WHERE MOD(TIMESTAMPDIFF(f.frequency_code, t.date, NOW()), t.frequency_num) = 0
This gets a syntax error when I run it. Now, if I replace f.frequency_code
with an actual word - MINUTE
, DAY
, etc. - it works. But those are exactly the words currently contained in f.frequency_code
.
Is it simply not doable to be able to use a table field in that location?