|
Posted by Erwin Moller on 07/08/07 09:30
DR wrote:
> Is it possible to search within concatenated fields in mySQL?
>
> This query works fine:
>
> SELECT CONCAT(title, description) AS searchInMe FROM content
>
> But when I try searching within 'searchInMe' I get an unknown column
> error. This is the (Dreamweaver generated) query:
>
> $query_search = sprintf("SELECT CONCAT(title, description) AS
> searchInMe FROM content WHERE searchInMe LIKE '%%%s%%'",
> $searchTerm_search);
>
> Is it that I cannot search within concatenated fields?
>
> Many thanks,
>
> Dmitri
Hi Dmitri,
What has that SQL to do with PHP?
But you could try to just use the concat instead of the alias.
Like this:
$query_search = sprintf("SELECT CONCAT(title, description) AS
searchInMe FROM content WHERE CONCAT(title, description) LIKE '%%%s%%'",
$searchTerm_search);
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|