How do you find information from the two tables?



  • How do you find information from two tables, how to make a sample?

    Let's say we need to find userid by specific parameters: He must have a color.blueAnd the name should be "Bob_name2"

    Note:

    User's number "2And there are two names.

    How can you do that?

    First table:

     |--------------|-----------|
     |userid        |color_name |
     |--------------|-----------|
     |1             |red        |
     |--------------|-----------|
     |2             |blue       |
     |--------------|-----------|
     |3             |red        |
     |--------------|-----------|
     |и.т.д.        | и.т.д     |
    

    Second table:

    |--------------|-----------|
    |userid        |List_name  |
    |--------------|-----------|
    |1             |Tom        |
    |--------------|-----------|
    |2             |Rise       |
    |--------------|-----------|
    |3             |Yura       |
    |--------------|-----------|
    |2             |Bob_name2  |
    |--------------|-----------|
    | и.т.д        |и.т.д      |
    


  • If only userid is true:

    select distinct A.userid
      from table1 A, table2 B
     where A.userid=B.userid
       and A.color_name='red' and B.List_name='Bob_name2'
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2