Commit 8c875ced authored by 李健华's avatar 李健华

修改获取联系人SQL

parent 324894ad
......@@ -23,6 +23,7 @@ public interface IContactRepository extends JpaRepository<Contact, Long> {
@Query(value = "update contact set name=?1,phone_no=?2,relation=?3 where id = ?4", nativeQuery = true)
void update(String name, String phoneNo, Integer relation, Long id);
@Query(value = "select *, max(`id`) as mid from contact where user_id=?1 GROUP BY phone_no ORDER BY id desc limit 2", nativeQuery = true)
// @Query(value = "select *, max(`id`) as mid from contact where user_id=?1 GROUP BY phone_no ORDER BY id desc limit 2", nativeQuery = true)
@Query(value = "select * from contact, (select max(`id`) as mid from contact where user_id=?1 GROUP BY phone_no ORDER BY id desc limit 2) as ids where contact.id=ids.mid", nativeQuery = true)
List<Contact> findContactForUserId(Long userId);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment