Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2009
    Posts
    3

    Unanswered: A bit complex for me..

    I have two tables in my db .

    articles
    --ARTICLE_ID
    --TITLE
    --DESCRIPTION
    --CONTENT

    galeries
    --ARTICLE_ID
    --GALLERY_ID
    --CONTENT

    I need to fulltext search these two tables. The ARTICLE_ID is the common key for both. The CONTENT in articles is empty when the article is a galery, so in that case for this ARTICLE_ID the content is stored in galeries table and can have multiple instances with the same ARTICLE_ID.
    The search keyword may be contained in TITLE,DESCRIPTION and CONTENT fields.

    I'm stack with this and I can't think a valid query.

    Any help will be apreciated.
    Thanks in advance.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    fulltext searching works on only one table at a time

    you might wish to consider separate fulltext indexes on the two tables, with a UNION to combine two search queries
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2009
    Posts
    3
    So there is no way to combine on the same search the TITLE,DESCRIPTION from articles table and CONTENT from galeries table??
    Even if with union i can't think a way to do this...

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    not with one fulltext search, no there isn't

    try writing two separate queries and i'll show you how to UNION them together
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Oct 2009
    Posts
    3
    But the two tables is related in some way with the ARTICLE_ID and the TILE,DESCRIPTION fields. The galeries query must contain TITLE and DESCRIPTION fields for the search to work..At least i can't think of an other way to search in galeries table and have result including these two fields in it.And in adition to this the two tables have different number of fields.

    Sorry for being so pester but i've been thinking of this for more that 6 hours and my brain is ready to collapse.

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by johniem
    Sorry for being so pester but i've been thinking of this for more that 6 hours and my brain is ready to collapse.
    okay, give your brain a rest

    i've suggested twice that you need separate queries, so let's break it down and take it real easy -- one query at a time!!!!!!

    please write a single query that will search only the articles table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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