Welcome Guest, Not a member yet? Register   Sign In
Distinct class in Mysql
#1

[eluser]nandish[/eluser]
table tbl_books

s_book_id s_book_title
121 Introduction to Mysql
122 Introduction to Mysql
123 Mysql Professional


SELECT disitnct s_book_title from tbl_books where s_book_title like '%mysql%'

Result is

Introduction to Mysql
Mysql Professional

SELECT disitnct s_book_id,s_book_title from tbl_books where s_book_title like '%mysql%'

Result is

121 Introduction to Mysql
122 Introduction to Mysql
123 Mysql Professional

so what is the sql statement to achieve this below result
121 Introduction to Mysql
123 Mysql Professional

Thanks In advance
#2

[eluser]rogierb[/eluser]
try a "group by" on title since a distinct on id will produce 3 distinct records




Theme © iAndrew 2016 - Forum software by © MyBB