Forum Moderators: open
I have this query for a search
$query = "SELECT
id,
title,
5 * (title REGEXP '$words') AS r1,
description REGEXP '$words' AS r2,
10 * (title REGEXP '$q') AS r3
FROM items
WHERE
(title REGEXP '$words') OR
(description REGEXP '$words') OR
(title REGEXP '$q')
ORDER BY
(r1 + r2 + r3) DESC"; I get the error unknown column r1, but I already used it as an alias.
I tried title as t1 .. ORDER BY t1 and that worked fine, so it's just an issue with the REGEXP I think.
Anyone know what's wrong?
$query = "SELECT
id,
title,
5 * (title REGEXP '$words') AS r1,
description REGEXP '$words' AS r2,
10 * (title REGEXP '$q') AS r3
FROM items
WHERE
(title REGEXP '$words') OR
(description REGEXP '$words') OR
(title REGEXP '$q')
ORDER BY
(5 * (title REGEXP '$words')) + (description REGEXP '$words') + (10 * (title REGEXP '$q')) DESC, title"; But I'd like to know why it doesn't know why it doesn't see those r1 r2 r3, and also will it slow it down doing all these regexps?