mysql - Querying a 1 to many table where the many side has at least one row -
have common schema, 2 tables.
users table contains columns id, name. checkins table contains columns user_id, checkin_date.
in hypothetical, users can have many instances of rows in checkins table.
checkin_date in case of type date
i want able query users have @ minimum 1 checkin in checkins table checkin after 2016.
i suggest using exists:
select u.* users u exists (select 1 checks c c.user_id = u.id , c.checkin_date >= '2016-01-01' );
Comments
Post a Comment