return id in chats sql query