Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 选择一列相同值内的第一行_Mysql - Fatal编程技术网

Mysql 选择一列相同值内的第一行

Mysql 选择一列相同值内的第一行,mysql,Mysql,我在一个名为message的表中有这些值: id message_id message 1 1 Hello sir 2 1 Hi dear. 3 2 Send by admin. 4 2 send by helper. 5 3 created b

我在一个名为message的表中有这些值:

id       message_id      message
1             1            Hello sir
2             1            Hi dear.
3             2            Send by admin.
4             2            send by helper. 
5             3            created by me. 
6             3            Done by user.
我在下表中看到的结果如下

id       message_id      message
1             1            Hello sir
3             2            Send by admin. 
5             3            created by me. 

请提供任何帮助。

您可以尝试,所需的只是使用一个选择唯一值的distinct子句

SELECT DISTINCT * from meassage;

使用分组信息\u id您能告诉我们您做了什么吗?请分享您的查询。
select M.id, M.message_id, M.message 
from message M
WHERE  M.ID = (SELECT MIN(M1.ID) FROM MESSAGE M1 WHERE M1.MESSAGE_ID = M.MESSAGE_ID) ;