2021年3月25日星期四

How to select column values based on the presence of a certain value in another column

I have a list of projects, and different companies bidding for those projects.

project_name   company_name   ­___________________________           abc      |        1      abc      |        2      abc      |        3      def      |        9      def      |        7      ghi      |        8      jkl      |        1      jkl      |        5      jkl      |        6      jkl      |        7  

I want to keep only the projects where company "1" is present, while also keeping the other competitors for the project. The desired result is:

project_name   company_name   ­___________________________           abc      |        1      abc      |        2      abc      |        3      jkl      |        1      jkl      |        5      jkl      |        6      jkl      |        7  

I have a feeling a subquery after WHERE is required to get that result, but I can't figure it out.

https://stackoverflow.com/questions/66809309/how-to-select-column-values-based-on-the-presence-of-a-certain-value-in-another March 26, 2021 at 08:14AM

没有评论:

发表评论