Jump to content

How to select and count unique rows?

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Gengar

Gengar

    Newbie

  • Members
  • Pip
  • 3 posts
I'm currently making an online game, based on Pokemon. You might not know about Pokemon, but it's pretty much you're a trainer and you go through and catch Pokemon, battle them, trade them, etc.

There's something called a PokeDex, which counts how many unique Pokemon you have. (Excluding doubles)

So say a user has 3 pikachus that belong to them in the 'Pokemon' table, but only 1 squirtle, if i selected it normally it would come out as "4 PokeDex completion".

Is there a way where I can only count 1 of each one? So pretty much only count 1 Pikachu and 1 Squirtle? Then display it?
Wouldn't want users taking advantage of having 6,000 PokeDex completion, when there's only 500 or so Pokemon...

#2
Vaielab

Vaielab

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 547 posts
You can group them with the command "group by"
select * from pokemon group by pokemon_name





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users