Jump to content

Archived

This topic is now archived and is closed to further replies.

emexinc

COUNT and GROUP BY from multiple columns...

Recommended Posts

...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

Share this post


Link to post
Share on other sites
Try this
[code]SELECT CONCAT(firstname, ' ', lastname) As fullname FROM database GROUP BY fullname[/code]

Share this post


Link to post
Share on other sites
Depending on what you're using this for, DISTINCT could also work:

[code]
SELECT DISTINCT firstname, lastname FROM database
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.