Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts

    Searching by relevancy on multiple tables

    I have 3 tables in my database (de_en,es_en,la_en), each a dictionary. Each has four columns (id,order,lang1,lang2 - lang1 and lang2 are replaced with the iso code for that language). I'm trying to build a query that will search a particular entry on all of the tables (expect to be adding more too), and sort them by relevancy. The lang1 and lang2 columns are fulltext indexes.

    This is what I've created for a single table.

    Code:
    $q = 'word';
    
    "SELECT *, MATCH (en) AGAINST ('" . $q . "') AS score FROM de_en WHERE MATCH (en) AGAINST ('" . $q . "') ORDER BY score DESC"
    I am unsure if or how to implement a join or union here, or if I should just query each table separately?
    Last edited by gnomeontherun; 04-28-2009 at 11:18 AM.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •