June 17, 2015

MySQL select query to COUNT only unique values.



If you used join query on parent table and child table and you want to fetch unique records from both table then see the below example

SELECT COUNT(DISTINCT(t1.id)) FROM table1 t1 left join table2 t2 on t2.id=t1.t2id

Enjoy!

1 comment:

The Future of Technology: Emerging Trends to Watch in 2025

Introduction As we navigate through 2025, the technological landscape continues to evolve at an unprecedented pace. Innovations that once se...