Question

i have two tables: songs and singers

and this my query:

    Select * FROM (
    SELECT
    idx,
    name,
    IDsinger,
    permission,
    (name LIKE '%XXX%') As relevancy,
    'table1' As t
    FROM `songs`
   where
   isActive<>'0' AND name LIKE '%XXX%'
UNION
    SELECT
        idx,
        name,
        CreationDate,
        permission,
        (name LIKE '%XXX%') As relevancy,
        'table2' As t
        FROM `singers`
        WHERE isActive<>'0' AND name LIKE '%XXX%'
) AS X
order by relevancy LIMIT 10

The problem is if i write "akon lonely" is not found result.

But if i write "akon" or "lonely" is found result.

And i would love suggestions for improving query..

Thanks

No correct solution

OTHER TIPS

Your result is correct. AKON is a singer and Lonely is the song. Neither the Song or the Singer is called Akon lonely.

Sounds like you are trying to do a more complicated form of searching like contains.

http://technet.microsoft.com/en-us/library/ms187787.aspx

You could try

name like '%' + @xxx + '%' or @xxx like '%' + name + '%'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top