0

I have a SQL query that I am trying to call that searches for words that match a keyword and then searches within a radius for the results

This query will work but only searches using "LIKE ?" not "LIKE %?%

connection.query("SELECT *, ( 3959 * acos (cos ( radians(?) )* cos( radians( lat ) )* cos( radians( lng ) - radians(?) )+ sin ( radians(?) )* sin( radians( lat ) ))) AS distance FROM job_posting where job_title like ? HAVING distance < 25",
        [lat, lng, lat, keyword], function(error, result) {
        console.log(result)
    })  

but I need %% around the keyword value at the end, something like this

job_posting where job_title like %?% HAVING distance < 25"  

I can't get it to run the query with the % signs at all. Any tips on how to fix this?

2
  • Can't you put the % signs around the keyword before passing it in as a query argument? Commented Nov 27, 2016 at 1:17
  • Yes I can. Thanks chap!! Commented Nov 27, 2016 at 1:36

1 Answer 1

1
var keyword = ("%" + req.query.keyword + "%")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.