Skip to content
Advertisement

Tag: semi-join

Sql to fetch records only if related other table records exist

Table: user id compId 1 comp1 2 comp1 Table: Company id name comp1 coke comp2 pepsi need a MYSQL query which should fetch company record only if it has one or more users, when passed a company id. I will have other where conditions on company table. Can this be achieved by joins? example 1: query(comp1) result: coke (atleast one

Advertisement