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

前端 未结 4 496
忘了有多久
忘了有多久 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 15:09

    These both query will give you result which you want....

    SELECT Carperts.id
      FROM Carpets INNER JOIN Curtains ON Carpets.colour = Curtains.colour
      and colour = 'light yellow';
    
    
    SELECT Carperts.id
      FROM Carpets INNER JOIN Curtains ON Carpets.colour = Curtains.colour
      WHERE colour = 'light yellow';
    

提交回复
热议问题