emexinc Posted August 26, 2006 Share Posted August 26, 2006 ...i've come close to answers, but nothing that has worked thus far......firstly i want to search a mysql database......but i need to search multiple columns......but i do not want duplications, so if two or more results are the same, i would like that to only be counted as one result......here's what i'm looking at...i have a mysql database with artist names, first and last...and i currently have four sets of these ( i've only come across four artists max thus far for one song with the songs that i have )...and i'd like to have the total number of artists beginning with the letter 'A' ( for example ) whether it be their first or last name that would start with that...but i do not want to the same artist counted more than once even if they have their name under multiple songs...any direction would be great...i'm sorta out of ideas at this point...thanks Quote Link to comment https://forums.phpfreaks.com/topic/18702-count-and-group-by-from-multiple-columns/ Share on other sites More sharing options...
Zane Posted August 26, 2006 Share Posted August 26, 2006 Try this[code]SELECT CONCAT(firstname, ' ', lastname) As fullname FROM database GROUP BY fullname[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18702-count-and-group-by-from-multiple-columns/#findComment-80637 Share on other sites More sharing options...
fenway Posted August 28, 2006 Share Posted August 28, 2006 Depending on what you're using this for, DISTINCT could also work:[code]SELECT DISTINCT firstname, lastname FROM database[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18702-count-and-group-by-from-multiple-columns/#findComment-81867 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.