easy question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    #1

    easy question

    I don't know SQL at all, but I have a problem now because I must use SQL in my PHP scripts.
    So please help me!

    I have 2 tables:
    id | name
    -----------
    1 | thing1
    2 | thing2
    3 | thing3
    4 | thing4

    id1 | id2
    --------
    1 | 1
    1 | 2
    1 | 3
    1 | 4
    2 | 1
    2 | 2
    .......

    from second table, with which SQL query I will take this table:
    thing1 | thing1
    thing1 | thing2
    thing1 | thing3
    thing1 | thing4
    thing2 | thing1
    .....
    ????

    Second question:
    Until now, instead of databases I was use many INI files.
    All work great with both of 2 cases but in case of INI files, changes are very easy.
    Is there an easy tool for edit databases?

    I use MySQL

    thanks for your response


  • Bruce Wolk

    #2
    Re: easy question

    <- Chameleon -> wrote:[color=blue]
    > I don't know SQL at all, but I have a problem now because I must use SQL in my PHP scripts.
    > So please help me!
    >
    > I have 2 tables:
    > id | name
    > -----------
    > 1 | thing1
    > 2 | thing2
    > 3 | thing3
    > 4 | thing4
    >
    > id1 | id2
    > --------
    > 1 | 1
    > 1 | 2
    > 1 | 3
    > 1 | 4
    > 2 | 1
    > 2 | 2
    > ......
    >
    > from second table, with which SQL query I will take this table:
    > thing1 | thing1
    > thing1 | thing2
    > thing1 | thing3
    > thing1 | thing4
    > thing2 | thing1
    > ....
    > ????
    >
    > Second question:
    > Until now, instead of databases I was use many INI files.
    > All work great with both of 2 cases but in case of INI files, changes are very easy.
    > Is there an easy tool for edit databases?
    >
    > I use MySQL
    >
    > thanks for your response
    >
    >[/color]
    Assuming t1 is your id|name table and t2 is your id1|id2 table,
    something like (untested)

    SELECT t1.name,t3.name FROM t2 LEFT JOIN t1 ON t2.id1=t1.id LEFT JOIN t1
    AS t3 ON t2.id1=t3.id

    Comment

    • Bruce Wolk

      #3
      Re: easy question

      <- Chameleon -> wrote:[color=blue]
      > I don't know SQL at all, but I have a problem now because I must use SQL in my PHP scripts.
      > So please help me!
      >
      > I have 2 tables:
      > id | name
      > -----------
      > 1 | thing1
      > 2 | thing2
      > 3 | thing3
      > 4 | thing4
      >
      > id1 | id2
      > --------
      > 1 | 1
      > 1 | 2
      > 1 | 3
      > 1 | 4
      > 2 | 1
      > 2 | 2
      > ......
      >
      > from second table, with which SQL query I will take this table:
      > thing1 | thing1
      > thing1 | thing2
      > thing1 | thing3
      > thing1 | thing4
      > thing2 | thing1
      > ....
      > ????
      >
      > Second question:
      > Until now, instead of databases I was use many INI files.
      > All work great with both of 2 cases but in case of INI files, changes are very easy.
      > Is there an easy tool for edit databases?
      >
      > I use MySQL
      >
      > thanks for your response
      >
      >[/color]
      Assuming t1 is your id|name table and t2 is your id1|id2 table,
      something like (untested)

      SELECT t1.name,t3.name FROM t2 LEFT JOIN t1 ON t2.id1=t1.id LEFT JOIN t1
      AS t3 ON t2.id1=t3.id

      Comment

      Working...