Hello. It is impossible to supplement the mysql query.

There are two tables: books, read

books - все книги, которые добавляют пользователи { id - Идентификатор. id_sender - Id отправителя книги. name - Название. time - время добавления. } read - кто на какую книгу подписан{ kto - id пользователя, который читает kogo - id пользователя, за которым следит пользователь } 

PS Changed the table for convenience.

My request:

 SELECT c.* FROM books c, read s '. 'WHERE c.id_sender = s.kogo AND s.kto = '.$id.' ORDER BY time DESC LIMIT 10 

Thank you in advance.

    2 answers 2

     kto - id пользователя, который читает // а что он читает какую книгу? где ID книги kogo - id пользователя, за которым следит пользователь 

    And where is the id of the book you are reading?

    Council initially correctly make the structure of the database and tables in it.

    So far, to be honest, the question sounds like this, but the insides sound different .

    • updated answer. - Artem
    • Maybe yes. You can still call the book a simple message that the user sends, and the user subscribes to the desired user and all his messages are displayed on one page. The principle of twitter is to follow whoever you want. If you can write a query with your fictional tables, I will be grateful, I will understand. Thank. - Elected

    The crux of the problem: showing your updates the same way, as if I was subscribed to myself.

     ... s.who = s.whom AND s.whom = '.$id.' ... 

    ?

    • yo, and I didn’t notice that :) here damn it ... - Artem
    • c.id_sender = s.whom AND s.whome = '. $ id.' - Only my updates are displayed. c.id_sender = s.whom AND s.who = '. $ id.' - Only someone else's updates are displayed on whoever is subscribed. - The Chosen
    • c.id_sender = s.whome AND s.who = '. $ id.' AND s.whom = '. $ Id.' - Nothing is displayed at all. - Chosen