Skip to content

Instantly share code, notes, and snippets.

@JunichiIto
Created March 29, 2012 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JunichiIto/2233293 to your computer and use it in GitHub Desktop.
Save JunichiIto/2233293 to your computer and use it in GitHub Desktop.
Query using EXISTS
-- The alternative query for the List 6.
-- This query can be executed against SQL Server.
-- http://gihyo.jp/dev/serial/01/sql_lifesaving/0005?page=4
SELECT s.sup,
s.city,
s.area
FROM Suppliers s
WHERE s.ship_flg = '可'
AND EXISTS
(SELECT *
FROM Manufacturers m
WHERE m.req_flg = '要'
AND m.city = s.city
AND m.area = s.area
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment