Creating query that returns id if condition is matched in rows from two tables

前端 未结 4 492
忘了有多久
忘了有多久 2021-02-03 14:11

I\'m learning SQL/dbms and using Postgres. I want to return rows that both have a certain value in a certain column. For example in tables Carpets and Curtain

4条回答
  •  天涯浪人
    2021-02-03 14:50

    If you want the result for matching in two table, then try this:

    select id
      from curtains
          ,carpets
      where curtain.color = carpets.color;
    

    This will return id where curtain.color = carpets.color

提交回复
热议问题