Ian Skinner said:
> My first suggestion would be an embed sub-query.

That would work if you add another level for the "Govt" condition.

> SELECT
>     fields
>
> FROM
>     Table.
>     (    SELECT
>             fields
>
>         FROM
>             TABLE
>
>         WHERE
>             Name LIKE "%Engineering%"
>     ) AS FooBar
>
> WHERE
>            FooBar.ID = Table.ID
> AND    Name LIKE "%Open%"
>
> Of course this assumes you are using a DBMS that allows sub-queries.
> I understand that not all of them do.

It is pretty trivial to rewrite as a self-join. I adapted thee names
of the original problem:

SELECT
    project_ID
FROM
    Table T1 INNER JOIN
      Table T2 USING (project_id) INNER JOIN
      Table T3 USING (project_id)
WHERE
    T1.Name LIKE '%Open%'
    AND
    T2.Name LIKE '%Engineering%'
    AND
    T3.Name LIKE '%Govt%'

Jochem
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to