Hello everyone.
Thanks all in advance for any help and suggestions.
This is table «forums» in MySQL:
DROP TABLE IF EXISTS `forums`;
CREATE TABLE `forums` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`connected` int(11) DEFAULT NULL,
`datum` datetime DEFAULT NULL,
`datum_update` datetime DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
`author` varchar(255) DEFAULT NULL,
`message` varchar(255) DEFAULT NULL,
`last_replies` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=396 DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of forums
-- ----------------------------
INSERT INTO `forums` VALUES ('392', '0', '2012-08-16 11:19:16', '2012-08-16 11:08:00', 'help me', 'Sandra', 'hello my friend', 'Sandra');
INSERT INTO `forums` VALUES ('394', '392', '2012-08-24 12:15:27', '2012-08-24 00:08:00', 'help me', 'admin', 'hi there', 'admin');
INSERT INTO `forums` VALUES ('395', '392', '2013-01-24 13:17:27', '2013-01-24 01:17:00', 'help me', 'Sammy', 'regards', 'Sammy');
You can’t have this output?
+-----+-----------+--------------------------+----------------------+---------+--------+----------+--------------+
| ID | connected | datum | datum_update | title | author | message | last_replies |
+-----+-----------+--------------------------+----------------------+---------+--------+----------+--------------+
| 395 | 392 | 2012-08-16 11:19:16 | 2013-01-24 01:17:00 | help me | Sandra | regards | Sammy |
+-----+-----------+--------------------------+----------------------+---------+--------+----------+--------------+
Because this query has this output:
mysql> SELECT
A.ID,
A.connected,
B.id,
B.connected,
A.datum,
B.datum_update,
A.title,
A.author,
B.message,
B.last_replies
FROM
forums a
JOIN forums b ON a.id = b.connected;
+-----+-----------+-----+-----------+---------------------+---------------------+---------+--------+----------+--------------+
| ID | connected | id | connected | datum | datum_update | title | author | message | last_replies |
+-----+-----------+-----+-----------+---------------------+---------------------+---------+--------+----------+--------------+
| 392 | 0 | 394 | 392 | 2012-08-16 11:19:16 | 2012-08-24 00:08:00 | help me | Sandra | hi there | admin |
| 392 | 0 | 395 | 392 | 2012-08-16 11:19:16 | 2013-01-24 01:17:00 | help me | Sandra | regards | Sammy |
+-----+-----------+-----+-----------+---------------------+---------------------+---------+--------+----------+--------------+
2 rows in set
mysql>