sql - Build a Query to get the informations from a specific user -


i'm building chat 3 tables.

conversation, conversation_reply , user

conversation columns

  1. id
  2. user_one
  3. user_two

conversation_reply columns

  1. id
  2. user_id
  3. conversation.id
  4. reply

user columns

  1. id
  2. username

i build list name users chating specific user.

example, id 711, , talking 3 persons, username 3 persons.

i'm having issues building query because user_one , user_two relative, id receiver can inserted user_one, or user_two. depends on user starts chatting first.

how can build query that?

thanks.

depending on rdbms can check if/else, case/when syntax. based on write statement:

select if (user_one=711) user_two else user_one conversation user_one=711 or user_two=711 

this pseudocode, idea should clear.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -