NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL help

Ophir Prusak prusak at gmail.com
Thu Oct 21 17:47:11 EDT 2004


Can you clue us in on what exactly you're trying to do here?
The best solution might be a different data structure but we'd really
need to understand what the tables represent.


On Thu, 21 Oct 2004 17:41:27 -0400, Stephen Musgrave
<stephen at musgrave.org> wrote:
> 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
> 
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org
>



More information about the talk mailing list