[thelist] mySQL queries

Beau Hartshorne beau at members.evolt.org
Mon Aug 12 14:52:54 CDT 2002


Jay, Jonathan: thank you!

Here's the working mySQL query (it does exactly what I want):

SELECT
	billing_job.*,
	billing_invoice.*,
	SUM(billing_invoice.amount) AS total_invoice,
	billing_job.amount AS j_amount
FROM
	billing_job
LEFT JOIN
	billing_invoice
ON
	(billing_job.job_id = billing_invoice.job_id)
GROUP BY
	billing_job.job_id
HAVING
	j_amount > total_invoice

Jay: there's a bunch of other tables (payment, client, etc), but I
didn't want to make the question any more complicated than it needed to
be.

All: sorry about the double post (I sent it originally via the wrong
email account, so I re-sent it with the right one, but both showed up).

<tip type="php">

If you are a php programmer (of any skill level) go read this article
(there are three parts):

http://www.zend.com/zend/art/mistake.php
http://www.zend.com/zend/art/mistake1.php
http://www.zend.com/zend/art/mistake2.php

It should help you learn or re-learn the best way to write code with
php.

</tip>

Thanks,

Beau





More information about the thelist mailing list