Okay so I'm trying to make it so I can make a conversation based messaging system with one table. The user messages a user and we put their id as sent_id
and the person who sent it is my_id
. Now my problem is, it is displaying, but I don't want it to display more than once. I've been using DISTINCT
but that doesn't seem to be working. Example table:
|--ID--|--MY_ID--|--SENT_ID--|
1 1 2
2 2 1
3 1 2
How do I make it only display the latest one?
(Also $my_id
is already escaped, don't worry lol)
SELECT `my_id`, `sent_id`, `time_stamp` FROM `messages` WHERE `sent_id`="'.$my_id.'" || `my_id`="'.$my_id.'"
Here is my table:
CREATE TABLE IF NOT EXISTS `messages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`my_id` text NOT NULL,
`sent_id` text NOT NULL,
`message` text NOT NULL,
`file` text NOT NULL,
`time_stamp` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;