NYCPHP Meetup

NYPHP.org

[nycphp-talk] Sssllloooowww Query

harvey list at harveyk.com
Mon Aug 1 12:16:23 EDT 2005


Thanks for the suggestion.
It seems to make sense...



At 11:21 AM 7/12/2005, Flavio daCosta wrote:

>On 07/12/2005 10:44 AM, harvey wrote:
> > I've got some code that works, but it's pretty slllooooww...
> > --snip--
>
>Unless I am missing something here, cant you just simplify it with a
>LEFT JOIN and use only 1 result set?
>
>-- untested --
>
>SELECT ms.subcat_id, ms.subcat_name, msab.show_fid
>FROM music_subcats AS ms
>LEFT JOIN music_showsandbands as msab
>   ON (ms.subcat_id = msab.band_fid AND msab.show_fid = $id)
>ORDER BY ms.subcat_name ASC
>
>Then something like:
>while ($row = mysql_fetch_assoc($allbands))
>{
>   $format = '<option value="%s"%s>%s</option>';
>   $selected = $row['show_fid'] > 0 ? ' selected' : '';
>   printf($format, $row['subcat_id'], $selected, $row['subcat_name'] );
>}
>
>-- untested --
>
>Forgive me if I totally missed the boat on this one ;)
>
>Flavio
>_______________________________________________
>New York PHP Talk Mailing List
>AMP Technology
>Supporting Apache, MySQL and PHP
>http://lists.nyphp.org/mailman/listinfo/talk
>http://www.nyphp.org




More information about the talk mailing list