How to specify the SELECT statement in the Mapper ?

6 views
Skip to first unread message

Neil.Lv

unread,
Nov 9, 2009, 1:44:38 AM11/9/09
to Lift
Hi all,

There is some example code:
###
SELECT id, name, sex, created_at, DAYOFWEEK(created_at,) as week,
(CURRENT_DATE) as t
FROM users
WHERE created_at > (CURRENT_DATE ) AND created_at < (CURRENT_DATE +
interval 2 day)
ORDER BY created_at ASC
###

How can i specify the SELECT statement that i don't want all the
columns and i want add the column as week
in the example code ?

Any help would be much appreciated!

Cheers,
Neil

Derek Chen-Becker

unread,
Nov 13, 2009, 9:50:20 AM11/13/09
to lif...@googlegroups.com
MetaMapper.findAllFields may work for what you're doing, but with the DAYOFWEEK conversion you may just have to go directly against the DB.

Derek

Neil.Lv

unread,
Nov 13, 2009, 12:35:20 PM11/13/09
to Lift
Is there a some simple code ~?

Thanks very much!

Cheers,
Neil

On Nov 13, 10:50 pm, Derek Chen-Becker <dchenbec...@gmail.com> wrote:
> MetaMapper.findAllFields may work for what you're doing, but with the
> DAYOFWEEK conversion you may just have to go directly against the DB.
>
> Derek
>

Timothy Perrett

unread,
Nov 13, 2009, 12:38:18 PM11/13/09
to lif...@googlegroups.com
If you mean raw sql:

DB.runQuery("SELECT * FROM abc")

Cheers, Tim

harryh

unread,
Nov 13, 2009, 1:52:17 PM11/13/09
to Lift
You'll be better off if you don't do it that way. Compute the day of
week from created_at in your scala code (personally I prefer joda time
for this sort of thing), instead of having the database do it for you.

Use the database to store and retrieve data, not to perform
calculations.

-harryh

Neil.Lv

unread,
Nov 14, 2009, 12:23:41 AM11/14/09
to Lift
Ok, Thanks for all your suggestion!

I'll try it again,

:)

Cheers,
Neil
Reply all
Reply to author
Forward
0 new messages