Convert search from SQL Server to MySQL

Posted by HAJJAJ on Stack Overflow See other posts from Stack Overflow or by HAJJAJ
Published on 2011-01-17T09:39:19Z Indexed on 2011/01/17 9:53 UTC
Read the original article Hit count: 217

Filed under:
|
|
|

hi, everyone.

i need to convert this one from SQL Server into MySQL

IF IsNull(@SearchText, '') <> '' BEGIN
SET @SearchText = '%' + @SearchText + '%'

SELECT NewsID,DeptID,DeptName,Title,Details ,NewsDate,img 
FROM @tbSearchtextTb
WHERE IsNull(Title,'')+IsNull(Details,'') LIKE @SearchText END

this code will search fro my search word in this columns: Title, Details.

i tried to convert this line but i had lots of errors:

these are my unsuccessful attempts

IF ISNULL(SearchText,'') <> '' THEN
SELECT CatID,CatTitle,CatDescription,CatTitleAr,CatDescriptionAr,PictureID,Published,DisplayOrder,CreatedOn
FROM tmp
WHERE CatTitle + CatDescription + CatTitleAr + CatDescriptionAr
LIKE  $SearchText;

and this one

IF $SearchText IS NOT NULL THEN
SELECT CatID,CatTitle,CatDescription,CatTitleAr,CatDescriptionAr,PictureID,Published,DisplayOrder,CreatedOn
FROM tmp
WHERE ISNULL(CatTitle,'') +ISNULL(CatDescription ,'') +ISNULL(CatTitleAr ,'') +ISNULL(CatDescriptionAr,'') LIKE  $SearchText;

and many many other ways but i could not find any.

so if you know please let me know, thanks and best regards.

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql