Multiple MySQL tables

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

    Multiple MySQL tables

    Hello!

    I need some help with tables in MySQL.
    I am making a colums of articles in my site.
    It has 3 posters that post articles.
    I make a little serach page to search for words into articles.

    I have the sintax below working, but I need to know what is the syntax
    to it select words from several tables. Every table is for a poster
    and all tables are in the same DB and have the same fields.

    ---------------
    $searchword="SE LECT * FROM table WHERE comment LIKE
    '%$searchstring %'";
    ---------------

    I tried
    ---------------
    $searchword="SE LECT * FROM table, table1, table2 WHERE selected_row
    LIKE '%$searchstring %'";
    ---------------

    and even make an ARRY for table, table1, table2 but it does not work.

    Can you help me?

    Sincerely,


    Carlos
  • Tom Thackrey

    #2
    Re: Multiple MySQL tables


    On 17-Aug-2003, area48@hotmail. com (Carlos Marangon) wrote:
    [color=blue]
    > I need some help with tables in MySQL.
    > I am making a colums of articles in my site.
    > It has 3 posters that post articles.
    > I make a little serach page to search for words into articles.
    >
    > I have the sintax below working, but I need to know what is the syntax
    > to it select words from several tables. Every table is for a poster
    > and all tables are in the same DB and have the same fields.
    >
    > ---------------
    > $searchword="SE LECT * FROM table WHERE comment LIKE
    > '%$searchstring %'";
    > ---------------
    >
    > I tried
    > ---------------
    > $searchword="SE LECT * FROM table, table1, table2 WHERE selected_row
    > LIKE '%$searchstring %'";
    > ---------------
    >
    > and even make an ARRY for table, table1, table2 but it does not work.
    >
    > Can you help me?[/color]

    You need to do a separate query for each table. The select from multiple
    table is used to join related rows in multiple tables together, I don't
    think that's what you want.

    --
    Tom Thackrey

    Comment

    • Why?

      #3
      Re: Multiple MySQL tables

      Why three tables for three different posters? Stick it in one table with
      an index on a 'poster' (some int) row?

      Why.

      Carlos Marangon wrote:
      [color=blue]
      > Hello!
      >
      > I need some help with tables in MySQL.
      > I am making a colums of articles in my site.
      > It has 3 posters that post articles.
      > I make a little serach page to search for words into articles.
      >
      > I have the sintax below working, but I need to know what is the syntax
      > to it select words from several tables. Every table is for a poster
      > and all tables are in the same DB and have the same fields.
      >
      > ---------------
      > $searchword="SE LECT * FROM table WHERE comment LIKE
      > '%$searchstring %'";
      > ---------------
      >
      > I tried
      > ---------------
      > $searchword="SE LECT * FROM table, table1, table2 WHERE selected_row
      > LIKE '%$searchstring %'";
      > ---------------
      >
      > and even make an ARRY for table, table1, table2 but it does not work.
      >
      > Can you help me?
      >
      > Sincerely,
      >
      >
      > Carlos[/color]

      Comment

      • Rainer Herbst

        #4
        Re: Multiple MySQL tables

        SQL provides the UNION operation, and it is/will be supported by newer
        MySQL versions. Check your mysql for it!

        Regards!
        Rainer

        Carlos Marangon schrieb:[color=blue]
        > Hello!
        >
        > I need some help with tables in MySQL.
        > I am making a colums of articles in my site.
        > It has 3 posters that post articles.
        > I make a little serach page to search for words into articles.
        >
        > I have the sintax below working, but I need to know what is the syntax
        > to it select words from several tables. Every table is for a poster
        > and all tables are in the same DB and have the same fields.
        >
        > ---------------
        > $searchword="SE LECT * FROM table WHERE comment LIKE
        > '%$searchstring %'";
        > ---------------
        >
        > I tried
        > ---------------
        > $searchword="SE LECT * FROM table, table1, table2 WHERE selected_row
        > LIKE '%$searchstring %'";
        > ---------------
        >
        > and even make an ARRY for table, table1, table2 but it does not work.
        >
        > Can you help me?
        >
        > Sincerely,
        >
        >
        > Carlos[/color]


        --
        ------------------------------------------------
        Rainer Herbst Linux - Registered
        ZEIK User #319157
        Universität Potsdam Usual disclaimers applies!
        ------------------------------------------------

        Comment

        Working...