You are here: Re: A better select? « PHP SQL « IT news, forums, messages
Re: A better select?

Posted by Paul Lautman on 02/20/07 21:12

John Drako wrote:
> This is for MySQL 5.0
>
> I took over some php/mysql code and I'm trying to optimize it if
> possible.
>
> I have one select statement on an indexed varchar field that gets
> built and used quite frequently. The field contains a series of
> keywords or tags. The query is supposed to find the user's selected
> tags and sometime find the rows that exclude certain tags.
>
> The existing query is like so:
>
> SELECT * FROM tableName WHERE tagsField LIKE '%tag1%' AND tagsField
> LIKE '%tag2%' AND tagsField NOT LIKE '%tag3%' AND NOT LIKE '%tag4%';
>
> the tags selected or excluded could reach as many as 30 making the
> query long.
>
> Is there a better way of doing this type of query?
>
> TIA
>
> John

First thing to say is that there is a better way of organising this type of
data! You should not have lots of values in a single field. You should have
a 1-to-many table where each tag occupies a separate row.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация