NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL help

Stephen Musgrave stephen at musgrave.org
Thu Oct 21 17:41:27 EDT 2004


So, I thought this query would be easy, but I've spent the better part 
of an afternoon on it.  To put it mildly:  it's very slow.  Any tips on 
how i might speed it up would be greatly appreciated.

SELECT
	a.column1
	COUNT(DISTINCT c.column1) as column1_count
FROM
	table1 a,
	table2 b,
	table3 d,
	table4 h
WHERE
	a.column2 = 1 AND a.column3 = 1
	AND (c.column3 = a.column3 AND c.column2 = a.column2)
	AND (d.column3 = a.column3 AND d.column2 = a.column2)
	AND (h.column3 = a.column3 AND h.column2 = a.column2)
GROUP BY
	a. column3
HAVING
	(column1_count >= 2)

Thanks,

Stephen




More information about the talk mailing list