Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:24:38+00:00 2026-06-05T07:24:38+00:00

I need to get the MATCH AGAINST scores from multiple tables with a common

  • 0

I need to get the MATCH AGAINST scores from multiple tables with a common key and combine their sums. The goal in the end is to create a search algorithm that will return rows with matching group_IDs. I have built a mysql query that has yet to run without error.

In case you want to know, this is the specific error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource

These are the tables I wish to search:


table: jn_groups

group_ID, name


table: jn_chat

chat_ID, group_ID, name


table: jn_events

event_ID, group_ID, title, description


My current query looks like this:

SELECT 
    g.group_ID AS group_ID,
    g.name AS name,
    SUM(gscore + cscore + escore) AS score,
    MATCH(g.name) AGAINST (" . $query . "') AS gscore,
    MATCH(c.name) AGAINST (" . $query . "') AS cscore,
    MATCH(e.title,e.description) AGAINST (" . $query . "') AS escore 
FROM jn_groups g 
LEFT JOIN jn_chat c ON g.group_ID = c.group_ID 
LEFT JOIN jn_events e ON g.group_ID = e.group_ID 
WHERE 
    MATCH(g.name) AGAINST (" . $query . "') 
    OR MATCH(c.name) AGAINST (" . $query . "')
    OR MATCH(e.title,e.description) AGAINST (" . $query . "') 
ORDER BY score

Any help making a query similar to that run would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:24:41+00:00Added an answer on June 5, 2026 at 7:24 am

    Two things which could be the reason for breaking this query:

    variable $query

    All your AGAINST-operators end with "', but start only with ". Make sure $query contains

    • valid data and
    • start with an '.

    Summate the partial results

    Your SUM won’t work, because it doesn’t know gscore, cscore and escore. It will look for field names instead. You can change this part of your statement like this (ofc replace hello world with your desired search term):

    ....
    SUM(
        (MATCH(g.name) AGAINST ('hello world'))
        + (MATCH(c.name) AGAINST ('hello world'))
        + (MATCH(e.title,e.description) AGAINST ('hello world'))
    ) AS score,
    ....
    

    Two advices:

    • Try running the query against your database with a SQL
      tool first (p.e. SQLyog, MySQL Workbench, phpMyAdmin or similar), to see if it is working like you want it to. There are a few other possibilities how to break this (p.e. no or wrong fulltext index definition, wrong field names and such), so you have better control about whats going wrong.
    • Be careful when using reserved variables like NAME in field names. Either escape them properly or – in my eyes better – avoid them.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get all the files in a folder that match a certain
I either get a you need a ; here or a best overloaded match
I need get documents from db by oid, like: Docs.objects(_id='4f4381f4e779897a2c000009') But how to do
I have two tables with a weak relation. I need get a text value
I have a need to match cold leads against a database of our clients.
I have next sql select site_id,count from tags where match (tag) against ('statistici' in
Just need get some vals located in application.ini(main ini) in the Controller plugin I
I need get all items these have no categories int? categoryId = null; var
Need to get the 10 word before and 10 words after for the given
Need to get an div with overflow:hidden; not to wrap its children. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.