简体   繁体   English

如何从表中获取所有数据,如果在同一列中重复相同的值,则该行应计数一次?

[英]How to get get all the data from table and if same value repeated in one column that row should count once?

leave_request table in my table emp_id column contains duplicate data 3 times. 我的表emp_id列中的Leave_request表包含3次重复数据。 i want to select all the data from the table and the duplicate data to count as once. 我想从表中选择所有数据,并将重复数据选为一次。 here i am providing the screenshot of my table structure 在这里,我提供了我的表结构的屏幕截图

You can try below - 您可以在下面尝试-

select max(id),emp_id, emp_name
from tablename
group by emp_id, emp_name

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 连接 - 从一个表中获取行然后获取另一个表中匹配的所有行? 但不应重复第一个表匹配行 - Joins - get row from one table then get all rows that match in another table? but first table matching row should not be repeated 从MySQL表的一列获取字符串值,并更新同一行的另一列值 - Get string value from one column of MySQL Table and update its other column value of same row 如何获取MySQL中的所有行只有两个表中的相同列值 - how to get all row in mysql only the same column value in two table php从所有行的同一列中获取特定数据 - php get specific data from the same column in all row 是否可以基于一个值对所有行进行计数,并获得具有最大计数的列名(mysql)? - Is that possible to count all row base on one value, and get the column name with largest count (mysql)? 如何从同一卷获取一列中的总和值并使用codeigniter显示所有行? - How to get sum value in a column from same roll and show all row using codeigniter? 如何在PHP Codeigniter中从一个表中获取特定列,并从另一表中获取所有其他数据 - How to get specific column from one table and all other data from other table in php codeigniter 如果一个表列为空,如何从另一表获取值 - How to get the value from the other table if one table column is empty sql连接中存在相同名称的两列时,如何从一个表列获取值 - How to get value from one table column when two columns of the same name exist in an sql join 如何从javascript中的表中获取列名和第一行值? - How to get column name and first row value from table in javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM