You are here: totally stumped .... whats wrong with LIKE %%?? « PHP SQL « IT news, forums, messages
totally stumped .... whats wrong with LIKE %%??

Posted by brendan on 06/21/05 15:09

have an interesting problem ... in a query with several parameters where I
use a LIKE rather than an '=' things go awry ... and I cannot work out why


am extracting from a mysql database ...

I want to extract all links that are
a) where COLUMN 'TYPE'='news' AND COLUMN keyword matches wildcard
%keyword%
OR
b) COLUMN 'TYPE'='image' (no keyword match)

so ... have the following query

"SELECT ... bla bla bla

( (links_DB.type = 'news' AND links_DB.keywords LIKE '%keyword%' ) OR
links_DB.type='image')

bla bla bla"

PROBLEM : this ONLY returns results where column 'TYPE'='news', not ones
where 'TYPE'='image'

HOWEVER :if I change the LIKE to an '=' thus:
((links_DB.type = 'news' AND links_DB.keywords='keyword' ) OR
links_DB.type='image')

I get both links_DB.type ='news' and links_DB.type='image' results!!
What is it about the LIKE clause that stops the second paremeter working???

any help greatly appreciated,
cheers,
brendan.

 

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

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