|
Re: Subtracting fields in the Where Clause: msg#00085jakarta.turbine.torque.user
In trying to simplify the query in order not to confuse the community, I overdid it, because it would appear that the solution would be a simple: Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 5); cr.add(SubscribersPeer.END_OF_SUBSCRIPTION_DATE, cal.getTime()); However, the problem I am facing is because in reality I am not comparing to a constant (5) but rather to a field from another table. The actual query is: SELECT user_id FROM details d, subscribers s WHERE s.app_id = d.app_id AND TO_DAYS(s.end_of_subscription_date) - TO_DAYS(SYSDATE()) = d.end_warning Given that the number of days until expiration varies from application to application, I want to get this as a dynamic value. I know a solution would be to do several queries (one for each application), but with a query such as the one presented above, I could do all of it in a single step. So executeQuery could also do the trick, but I would like to avoid it in order to obtain DB independence. Thanks for any help. Ruy --- Ruy Diaz Jara <diaz_ruy@xxxxxxxxx> wrote: > Hi, > > I'm trying to familiarize myself with Torque and so far I've been having some > trouble porting SQL statements to Criteria. Currently, what I am attempting > to > do is to get the following query (originally MySQL 4.0): > > SELECT user_id > FROM subscribers s > WHERE to_days(s.end_of_subscription_date) - to_days(SYSDATE()) = 5 > > The query extracts a list of users whose subscriptions to a service will end > in > 5 days. How can I add a Criterion with a mathematical expression? Is it > possible or do I have to use BasePeer.executeQuery()? > > Regards > Ruy > > > > __________________________________ > Do you Yahoo!? > Meet the all-new My Yahoo! - Try it today! > http://my.yahoo.com > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: torque-user-unsubscribe@xxxxxxxxxxxxx > For additional commands, e-mail: torque-user-help@xxxxxxxxxxxxx > > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Subtracting fields in the Where Clause: 00085, Ruy Diaz Jara |
|---|---|
| Next by Date: | Join or Caching (??): 00085, Saravana Krishnan |
| Previous by Thread: | Subtracting fields in the Where Clausei: 00085, Ruy Diaz Jara |
| Next by Thread: | Join or Caching (??): 00085, Saravana Krishnan |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |