I would like to do something like this.... SELECT * FROM orders,subscriptions WHERE orders.subscription_id = subscriptions.id created < created - INTERVAL subscriptions.term subscriptions.unit;
But I get "ERROR 1064: You have an error in your SQL syntax near 'subscriptions.unit)'" If I replace subscriptions.unit to 'YEAR' it works fine. The 'subscriptions' table has 2 columns: term (int) and unit (enum). The enum types for unit are 'YEAR', 'MONTH', etc... Anyone have any ideas on how to use MySQL's wonderful date & time functions to accomplish what I am trying to do? I'd like to avoid using approximate techniques such as using 86400 seconds for a day, since calculating months and years _accurately_ is very involved. P.S. DATE_SUB(created, INTERVAL subscriptions.term subscriptions.unit) had the same parse error. Regards, Erik Osterman -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]