Есть таблица сообщений: t_message:
| Код | id user1 - отправитель user2 - получатель text status data
|
Мне нужно выбрать все сообщения между мной ($user_id) и другим человеков ($profile_id). Пытаюсь это сделать вот так:
| Код | $query="select * from `t_message` where `id` in (select `id` from `t_message` where `user1`='$user_id' or `user2`='$user_id') or `id` in (select `id` from `t_message` where `user1`='$profile_id' or `user2`='$profile_id') order by `id` desc limit ".$b.",10";
|
где $b - номер сообщения, с которого начинать показывать переписку. Но выдает ошибку:
| Код | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '10' at line 1
|
И не работает аналогичный запрос на изменения статуса у всех сообщений из этой переписки на "прочитанное":
| Код | $query="update `t_message` set `status`='0' where `id` in (select `id` from `t_message` where `user1`='$user_id' or `user2`='$user_id') or `id` in (select `id` from `t_message` where `user1`='$profile_id' or `user2`='$profile_id')";
|
Выдает ошибку:
| Код | You can't specify target table 't_message' for update in FROM clause
|
|