From: Fred Lindberg Date: March 30 1999 8:43pm Subject: Re: Complicated Query List-Archive: http://lists.mysql.com/mysql/1203 Message-Id: <19990330204558.9625.qmail@id.wustl.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit On Tue, 30 Mar 1999 12:33:05 -0800, Mike Machado wrote: >Now I want to know everyone who was logged in between '1999-03-29 >02:00:00' and '1999-03-29 04:00:00' If "between" means "at any time in the interval", the set you want is the union of: logged in before [low] and did not log out before [low] (already on when the interval started) logged in after [low] and before [hi] (during the interval) So if your range is Tin...Tout ... WHERE Tin < [low] AND Tout > [low] OR Tin > [low] AND Tin < [hi] If "between" means "during the entire interval" you're looking for Tin < [low] and Tout > [hi]. Also, depending on what you mean with between, the equal condition may need to be included (i.e. > maybe should be >=, etc). -Sincerely, Fred (Frederik Lindberg, Infectious Diseases, WashU, St. Louis, MO, USA)