Re: Query of a query inconsistancies

2004-07-08 Thread Jochem van Dieten
Barney Boisvert wrote: > That's still not the same query; it'll only work if each user only has a > single record in the timelog table.  Or did you mistype and all the > 'timelogID's in the subquery should be replaced with 'userID's? Only if you mistyped it in the original :-) Jochem [Todays Th

RE: Query of a query inconsistancies

2004-07-08 Thread Barney Boisvert
;s why MySQL has that feature" is really reasonable, but it's damn near irrelevant anyway. Cheers, barneyb > -Original Message- > From: Jochem van Dieten [mailto:[EMAIL PROTECTED] > Sent: Thursday, July 08, 2004 3:59 PM > To: CF-Talk > Subject: Re: Query of a quer

Re: Query of a query inconsistancies

2004-07-08 Thread Jochem van Dieten
Barney Boisvert wrote: >> If only one of them is unique, you need to normalize your data :) > > I need to pull out a list of users and the number of hours they've worked in > the past year: > > SELECT user.userID, user.firstname, user.lastname, >   SUM(timelog.endTime - timelog.startTime) AS time

RE: Query of a query inconsistancies

2004-07-08 Thread Barney Boisvert
y 08, 2004 3:06 PM > To: CF-Talk > Subject: Re: Query of a query inconsistancies > > Barney Boisvert wrote: > >> For some reason in MySQL this braindead syntax is allowed, but > >> even the manual says the result may be 'unpredictable' > > > > It&#

Re: Query of a query inconsistancies

2004-07-08 Thread Jochem van Dieten
Barney Boisvert wrote: >> For some reason in MySQL this braindead syntax is allowed, but >> even the manual says the result may be 'unpredictable' > > It's not totally brain dead. I disagree :) > I agree that if you don't know what you're > doing, you shouldn't use it, but it is nice where you

RE: Query of a query inconsistancies

2004-07-08 Thread Barney Boisvert
> For some reason in MySQL this braindead syntax is allowed, but > even the manual says the result may be 'unpredictable' It's not totally brain dead.  I agree that if you don't know what you're doing, you shouldn't use it, but it is nice where you've got a series of columns that you're grouping

Re: Query of a query inconsistancies

2004-07-08 Thread Todd Ashworth
Ah. That link explains it all.  The OrderDate fields are not unique. Thanks. - Original Message - From: "Jochem van Dieten" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Thursday, July 08, 2004 17:38 PM Subject: Re: Query of a query inconsis

Re: Query of a query inconsistancies

2004-07-08 Thread Jochem van Dieten
Todd Ashworth wrote: >> Todd <[EMAIL PROTECTED]> wrote: >>> >>> >>> SELECT *, COUNT(*) AS totalcount, SUM(Cost) AS totalcost >>> FROM orders, orderitems >>> WHERE orders.OrderID = orderitems.OrderID >>> AND OrderDate >= '#DateFormat(StartTime, "-mm-dd")#' >>> GROUP BY U

Re: Query of a query inconsistancies

2004-07-08 Thread Todd Ashworth
It does.  On the first line I'm doing a SELECT *.  that would include the OrderDate column, would it not? - Original Message - From: "I-Lin Kuo" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Thursday, July 08, 2004 10:31 AM Subject:

Re: Query of a query inconsistancies

2004-07-08 Thread I-Lin Kuo
Logically, they're different. You shouldn't get any results by moving the orderdate condition to the bottom query, because qryGetRepeatSales doesn't have a date column --- Todd <[EMAIL PROTECTED]> wrote: > I have these 2 queries: > > > name="qryGetRepeatSales"> > SELECT *, COUNT(*) AS totalc

Query of a query inconsistancies

2004-07-07 Thread Todd
I have these 2 queries:     SELECT *, COUNT(*) AS totalcount, SUM(Cost) AS totalcost     FROM orders, orderitems     WHERE orders.OrderID = orderitems.OrderID     AND OrderDate >= '#DateFormat(StartTime, "-mm-dd")#'     GROUP BY UserID     HAVING totalcount > 1     SELECT SUM(totalcost) AS