Hi, I have table person, some persons have the same first name: firstname lastname John Lennon John Lewis John Chow John McCain ... I use this query SELECT lastname FROM person WHERE firstname='John'; Now I wanna select only one rows, whose lastname has the min. value length (in this case, it's Chow - 4 characters) How can I do that?
i would try with select lastname, firstname, min(len(firstname)) from person group by lastname len is a function for lenght. you should have something similar with the DB you are using.
A simple research in Google with "MySql lenght" let me found this function : CHAR_LENGTH() Return number of characters in argument Remember! Google is your friend and if you want to succeed on programming, you will have sometimes to do yourself the research. Hope this help!