I have four tables:
shops (shop,shop_id), products(product_id,date),
shops.shop and shops.shop_id values are unique
I wish to COUNT the number of distinct shops for which at least one row in the products table exists such that shops.shop_id=products.sho
oduct_id, products.date >= users.prior_login, users.user_id=22, and sex.sex=0.
Right now I am trying:
SELECT COUNT (shop_id) AS total_shops FROM shops
WHERE EXISTS (
SELECT * FROM
products, sex WHERE
(products.date >= (SELECT
user_id = 22)))
This produces a syntax error. What am I doing wrong?