Jump to content

Recommended Posts

My sql query fails to work :(

 

I am new to this BOOLEAN MODE search...

 

SELECT DISTINCT MATCH(title, description) AGAINST ('search string' IN BOOLEAN MODE) d.id, d.title, d.description, m.image FROM deals d JOIN merchants m ON m.id = d.merchant WHERE d.status=1 AND MATCH(d.title, d.description) AGAINST ('search string' IN BOOLEAN MODE) ORDER BY d.added DESC LIMIT 0,24

 

here is the error I get...

 

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 '.id, d.title, d.description, m.image FROM deals d JOIN merchants m ON m.id = d.merchant WHERE d' at line 1

 

If I remove the "d." from "d.id" the query runs but it grabs the id from merchants table. Bad naming on my part but I hope I can solve it without having to change the column name.

 

I am probably overlooking something really simple, cheers for any help

Link to comment
https://forums.phpfreaks.com/topic/193934-boolean-distinct-match-search/
Share on other sites

Sorry the code is

 

SELECT 
DISTINCT MATCH(title, description) 
AGAINST ('search string' IN BOOLEAN MODE) 
AS d.id, d.title, d.description, m.image 
FROM deals d 
JOIN merchants m 
ON m.id = d.merchant 
WHERE d.status=1 
AND MATCH(d.title, d.description) 
AGAINST ('search string' IN BOOLEAN MODE) 
ORDER BY d.added DESC 
LIMIT 0,24

 

the as got lost somehow

I worked out what i was doing wrong

 

SELECT 
DISTINCT MATCH(title, description) 
AGAINST ('search string' IN BOOLEAN MODE) 
AS relevance,
d.id, d.title, d.description, m.image 
FROM deals d 
JOIN merchants m 
ON m.id = d.merchant 
WHERE d.status=1 
AND MATCH(d.title, d.description) 
AGAINST ('search string' IN BOOLEAN MODE) 
ORDER BY relevance DESC 
LIMIT 0,24

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.