multiple records and tables query - help

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

    multiple records and tables query - help

    Not sure if I should post in php or sql,

    $query = "SELECT page.*, url_pages.* FROM `page` LEFT JOIN `keywords`
    USING(`page_id` ) LEFT JOIN URL_PAGES USING (`page_id`) WHERE
    MATCH(`keywords `.`keyword_txt` ) AGAINST ('$keyword'IN BOOLEAN MODE)";

    I got a keyword table, the fulltext finds the word in the keywords table
    and relates the page_id field to identical fields in the page table and
    the url table.

    keyword table
    page_id keyword
    1 foo

    page table
    page_id title description
    1 my urls It' my webpage

    url table
    page_id url
    1 goglle1.com
    1 goglle2.com

    I want *one reord* rendering like this:

    my urls It' my webpage goglle1.com goglle2.com

    ie. the user sees one record

    BUT in my mysql/php attempts i get this rendering:
    my urls It' my webpage goglle1.com
    my urls It' my webpage goglle2.com

    What's the strategy to combine into *one* record? I can split things up
    into two separate querys? I need help. Thanks
  • Tim Roberts

    #2
    Re: multiple records and tables query - help

    leegold2 <leegold@nospam .net> wrote:
    [color=blue]
    >Not sure if I should post in php or sql,
    >
    >$query = "SELECT page.*, url_pages.* FROM `page` LEFT JOIN `keywords`
    >USING(`page_id `) LEFT JOIN URL_PAGES USING (`page_id`) WHERE
    >MATCH(`keyword s`.`keyword_txt `) AGAINST ('$keyword'IN BOOLEAN MODE)";
    >...
    >I want *one reord* rendering like this:
    >
    >my urls It' my webpage goglle1.com goglle2.com
    >
    >ie. the user sees one record
    >
    >BUT in my mysql/php attempts i get this rendering:
    >my urls It' my webpage goglle1.com
    >my urls It' my webpage goglle2.com
    >
    >What's the strategy to combine into *one* record? I can split things up
    >into two separate querys? I need help. Thanks[/color]

    You can't do this with SQL. You will have to process the results in code.
    Scan through the query results, accumulating the URL field, while watching
    for the primary key field to change.
    --
    - Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

    Comment

    Working...