The parser does not execute the query before it parses it. Thus you
cannot do that. Use Code, and or have an idea what the INTERVAL UNIT is
prior to executing the query.



- Dathan Vance Pattishall
  - Sr. Programmer and mySQL DBA for FriendFinder Inc.
  - http://friendfinder.com/go/p40688


-->-----Original Message-----
-->From: Erik Osterman [mailto:[EMAIL PROTECTED]
-->Sent: Wednesday, November 12, 2003 4:05 AM
-->To: [EMAIL PROTECTED]
-->Subject: A question on INTERVAL
-->
-->
-->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]




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to