Home > database >  IM table to query paging, how to implement?
IM table to query paging, how to implement?

Time:04-09

 CREATE TABLE ` user_msg ` (
` msg_id ` bigint (15) NOT NULL AUTO_INCREMENT COMMENT 'message ID,
` parent_msg_id ` bigint (15) the DEFAULT '0' COMMENT 'father message ID,
` user_id_to ` bigint (15) NOT NULL COMMENT 'receive the user ID,
` user_id_to_read ` tinyint (1) the DEFAULT '0' COMMENT 'receiving user unread,
` user_id_from ` bigint (15) DEFAULT NULL COMMENT 'to send the user ID,
` user_id_from_read ` tinyint (1) the DEFAULT '0' COMMENT 'send users are not reading,
` content ` varchar (250) NOT NULL COMMENT 'message content,
` last_content ` varchar (250) the DEFAULT NULL COMMENT 'last message content,
` ctime ` int (10) the DEFAULT '0' COMMENT 'creation time,
PRIMARY KEY (` msg_id `),
The KEY ` sectread ` (` user_id_to `) USING HASH,
The KEY ` sect ` (` user_id_to `, ` user_id_from `),
The KEY ` select ` (` msg_id `, ` parent_msg_id `, ` ctime `)
) ENGINE=InnoDB AUTO_INCREMENT=16714 DEFAULT CHARSET=utf8 COMMENT='user direct messages/notes;


Table contains the user A and user B, send each other information, I'm doing A list page, how to query A user list of DMS data?
Table is such A to B, B returned to A A, two data are listed in the table, the first user_id_from=A, user_id_to=B, the second user_id_from=B, user_id_to=A,

Have bosses can guide, how to write SQL? To page
  • Related