[thelist] mySQL queries

Steve Lewis slewis at macrovista.net
Mon Aug 12 15:13:43 CDT 2002


Beau Hartshorne wrote:

> 2. It will return jobs that have been fully invoiced. The SUM function
> doesn't seem to work in the WHERE clause. (I can hack around this by
> using PHP to ignore rows where the amount still owing is a positive
> number. Yuk.)
It occurs to me now that I didn't read this part carefully enough.  If
you want to use an aggregate function (SUM AVG COUNT etc) in a WHERE
clause, look at HAVING in the MySQL documentation.  Essentially you will
use a HAVING clause instead of a WHERE clause.

My excuse: I'm still on vacation till tomorrow.  :)

--Steve

> 3. All my worries would go away if each billing_job row kept its own
> track of how much money had been paid and how much was owing. (Yuk. I'm
> trying to do this properly.)

And as Jay said, where is your 'payments' table.. just because you
mailed an invoice doesn't mean you got the check yet.  :)





More information about the thelist mailing list