date comparison query

2012-03-16 Thread Simon Wilkinson
Hi, I have a table that holds two datetime columns. I am trying to find values from this table that fall into specific time ranges, but am getting some strange results. For example, if I try to find rows where the difference between the two column is between 47 and 48 weeks, I get back a result

Re: change from an OR to an AND condition

2011-09-27 Thread Simon Wilkinson
in this instance, what I'm looking for are the entries where they have two entries in entries_tags with tag ids 5 and 6, instead of entries that have either. Thanks again, Simon On 27 September 2011 09:46, Simon Wilkinson wrote: > Hi, > > I have a query where I'm using a

change from an OR to an AND condition

2011-09-27 Thread Simon Wilkinson
Hi, I have a query where I'm using a left outer join to connect two tables, entries and entries_tags, where entries_tags is a join table between entries and another table, tags. In my query I am selecting values from the entries table where the entries have any of the provided tags - WHERE entrie

Re: optimizing query

2011-01-21 Thread Simon Wilkinson
indexes. Cheers, Simon On 19 January 2011 02:11, Steve Meyers wrote: > On 1/18/11 10:22 AM, Simon Wilkinson wrote: > >> SELECT articles.* FROM articles INNER JOIN newsletters ON >> articles.newsletter_id = newsletters.id INNER JOIN users ON users.id = >> newsletters.user_i

optimizing query

2011-01-18 Thread Simon Wilkinson
Hi, I am trying to optimize the following query: SELECT articles.* FROM articles INNER JOIN newsletters ON articles.newsletter_id = newsletters.id INNER JOIN users ON users.id = newsletters.user_id WHERE users.id =12 AND MONTH(articles.created_at) = '12' AND DAY(articles.created_at) = '5' ORDER B

Re: help with query

2011-01-12 Thread Simon Wilkinson
Thank you, that did the trick. Simon On 11 January 2011 12:09, Steve Meyers wrote: > On 1/11/11 9:31 AM, Simon Wilkinson wrote: > >> select users.id from users where users.id in (select newletters.user_id >> from >> newletters left join articles on newletters.id

help with query

2011-01-11 Thread Simon Wilkinson
Hi, I have 3 tables that I am trying to search across, and could use some help on how to structure the query. I have a users table, a newsletter table, and an articles table. The newsletter table has a user_id column, and the articles table has a newsletter_id column. A user can have multiple n