子表多数据,模糊查询子表而不重复获得父表数据

 select p1.id, p1.title, p1.views, p1.update_time, p1.user_id from tyc_raise as p1 join tyc_raise_text as p2 on p2.raise_id = p1.id where p1.type = 1 and p1.top = 0 and (p1.title like '%测试%' or p2.text like '%测试%' or user_id = (select user_id from tyc_user where nickname = '测试')) order by update_time desc limit 0, 10

拿到重复数据
图片说明

做一个搜索功能,要查raise表数据。通过子表tyc_raise_text模糊查询时会拿到多个raise表id

主表
图片说明
附表
图片说明

用 DISTINCT