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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

dataset - MPAndroidchart returning no chart Data available -

post - imageshack API cURL -