Web Worm
Web Worm

Reputation: 2066

php ajax one to one chat problem

i am trying to make php ajax one to one chat.............my problem is that how can i fetch the chat messages from table by both user1 and user2........ my database table has........

id, from, to, text, time fields..............

what would be the query to show the messages from both users with their respective names....

Upvotes: 0

Views: 415

Answers (1)

Victor Nicollet
Victor Nicollet

Reputation: 24577

The most readable would be, I believe, of the form:

SELECT <fields> FROM <table>
WHERE (from = :me AND to = :him OR from = :him AND to = :me)
  AND <more conditions>

Upvotes: 1

Related Questions