MySQL security group view permission query
SELECT DISTINCT record.id AS id, details from record 
LEFT JOIN record_group ON record.id = record_group.record_id
WHERE record_group.group_id IN (SELECT group_id from user_group WHERE user_id = 2)


http://sqlfiddle.com/#!9/e40ee6/12