Table with 3 queries

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

    Table with 3 queries

    Hi!!!!

    I´m stuck with a problem

    I have to make a table with the information of three different queries.
    The table has 4 columns x n rows. The first and second columns must be
    filled with the result of the first query, the third, with the result
    of the second query and the fourth with the result of the third query.
    All queries has the same number of results and the count(result) > 1

    I made different combinations of while's but no one seems to work.

    Any help or reference???

    Thanks in advance!!!

    Ezequiel

  • Oli Filth

    #2
    Re: Table with 3 queries

    zek2005 said the following on 29/12/2005 03:08:[color=blue]
    > Hi!!!!
    >
    > I´m stuck with a problem
    >
    > I have to make a table with the information of three different queries.
    > The table has 4 columns x n rows. The first and second columns must be
    > filled with the result of the first query, the third, with the result
    > of the second query and the fourth with the result of the third query.
    > All queries has the same number of results and the count(result) > 1
    >
    > I made different combinations of while's but no one seems to work.
    >[/color]

    How are you associating different rows of the separate queries?
    e.g. if Query 1 gives:

    col1 col2
    ------------
    A X
    B Y
    C Z

    and Query 2 gives:

    col1
    ----
    D
    E
    F

    and Query 3 gives:

    col1
    ----
    G
    H
    I

    How do you expect MySQL (are you using MySQL? You didn't actually say)
    to know how to combine these into one table?

    There's nothing about that data that implies it should be combined as
    follows:

    col1 col2 col3 col4
    ----------------------------
    A X D G
    B Y E H
    C Z F I

    In which case, it's usually the wrong approach to put unrelated data
    into one table.

    If the data *is* related in some way, then that means that you should be
    able to perform just one query, rather than three separate queries.

    --
    Oli

    Comment

    Working...