SQL select help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • leegold2

    SQL select help


    Hi, probably a newbie type question. Right now the query below searches
    word.word_word field for hits. I want to add page.descrip and page.title
    to the search and search these fields with LIKE '%$kewyord%' too. It
    would be, if word.word_word OR page.descrip OR page.title LIKE
    '%$kewyord%'. How would I add that optimumly to the SQL below? Thanks,
    Lee G.
    $result = mysql_query(" SELECT p.page_url AS url,
    COUNT(*) AS occurrences, p.title AS title,
    p.descrip AS descrip, p.page_id AS id
    FROM page p, word w, occurrence o
    WHERE p.page_id = o.page_id AND
    w.word_id = o.word_id AND
    w.word_word LIKE '%$keyword%'
    GROUP BY p.page_id
    ORDER BY occurrences DESC" );
  • Bill Karwin

    #2
    Re: SQL select help

    leegold2 wrote:
    [color=blue]
    > Hi, probably a newbie type question. Right now the query below searches
    > word.word_word field for hits. I want to add page.descrip and page.title
    > to the search and search these fields with LIKE '%$kewyord%' too. It
    > would be, if word.word_word OR page.descrip OR page.title LIKE
    > '%$kewyord%'.[/color]

    I can't think of any better way than doing it with three predicates, for
    example:

    word.word_word LIKE '%$keyword%'
    OR page.descrip LIKE '%$keyword%'
    OR page.title LIKE '%$keyword%'

    Bill

    Comment

    Working...