hi guys i am really new to sql so please be gentle with me on this one. i am trying to run a Query that will pull all records that have been either created_at or updated_at within the last two weeks.
i did some reading at this is what i have so far
SELECT * FROM sms_development.scores WHERE DATE(created_at) = CURDATE() - INTERVAL 14 DAY AND CURDATE() OR DATE(updated_at) = CURDATE() - INTERVAL 14 DAY AND CURDATE();
this looks really huge and its not dry at all. and its not working for some reason. if i enter it into MySQL workbench it give me a green light but i dont know if i have made a gramatical error or something. but no records are pulled.
any advice or techniques that are helpful are much appreciated
You should probably do as much of this through Rails finders as possible; they’re at least partially portable to other data storage engines, so if you, say, switch from SQLite to Postgres you won’t have to rewrite (as much) code.
I would do this like so: