I have the above sql code and when i will run it return error, can you help me how to resolve it?
$keyword= variable in php the sql table is data(id,source,title,description,h1) $sql = "SELECT * , MATCH (title) AGAINST ('$keyword') AS rel1, MATCH (source) AGAINST ('$keyword') AS rel2, FROM data WHERE MATCH (title,source) AGAINST ('$keyword') ORDER BY (rel1*1.5)+(rel2) LIMIT $offset, $rec_limit ";
error sql You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM data WHERE MATCH (title,source) AGAINST ('') ' at line 4
my webserver have Server: Localhost via UNIX socket Server version: 5.1.51 mysql php server ngix server
You have added an extra comma. Try this:
SELECT * , MATCH (title) AGAINST ('$keyword') AS rel1, MATCH (source) AGAINST ('$keyword') AS rel2 FROM data WHERE MATCH (title,source) AGAINST ('$keyword') ORDER BY (rel1*1.5)+(rel2) LIMIT $offset, $rec_limit
Also you might need to replace ORDER BY (rel1*1.5)+(rel2) with matches, not sure aliases work here as well.