I have the following SQL statement:
SELECT
g.*,
(
MATCH (g.GameTitle) AGAINST ('call of duty')
OR g.GameTitle SOUNDS LIKE 'call of duty'
)
AS MatchValue,
p.id AS platformid,
p.alias AS PlatformAlias,
p.name,
p.icon
FROM
games AS g,
platforms AS p
WHERE
(
(
MATCH (g.GameTitle) AGAINST ('call of duty')
OR g.GameTitle SOUNDS LIKE 'call of duty'
)
OR
(
MATCH (g.Alternates) AGAINST ('call of duty')
OR g.Alternates SOUNDS LIKE 'call of duty'
)
)
AND g.Platform = p.id
ORDER BY MatchValue DESC
Which returns a correct set of results when matching against a FullText Index, however the “MatchValue” that is reported is of a Boolean nature (0 or 1) only.
If I remove line 5 of the statement:
OR g.GameTitle SOUNDS LIKE 'call of duty'
I get decent match values ranging from say around 5.23 to 15.56, but I lose some functionality when matching against “Alternates”.
I’m not brilliant with SQL and it has taken me several days to get it functioning this much…
Is there any way to get lines 5 and 6 to return a non boolean match value so that my results are properly ordered?
Thanks in advance 😉
When you say
'ABC' OR (3 > 2)you are asking for aBOOLresult. You cannot either get a string or a boolean. In the above case, the string'abc'translates to boolean 0, since it does not represent a number.Since it does not make much sense in
ORing a string and a boolean, I would separate the two:Note the change:
This way you get it both ways: one time you get the boolean value, in a nother column you get the (possible) match.