# Getting lowest three different items in same table with mysql

**URL:** <https://forum.kirupa.com/t/getting-lowest-three-different-items-in-same-table-with-mysql/323322>\
**Category:** Uncategorized\
**Created:** [June 25, 2011, 9:54am UTC](https://forum.kirupa.com/t/getting-lowest-three-different-items-in-same-table-with-mysql/323322 "2011-06-25T09:54:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DemonGibi](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@DemonGibi](https://forum.kirupa.com/u/DemonGibi)\
**Post date:** [June 25, 2011, 9:54am UTC](https://forum.kirupa.com/t/getting-lowest-three-different-items-in-same-table-with-mysql/323322/1 "2011-06-25T09:54:24Z")

</div>

Hi guys…  
I’m very new to these server-side things…  
I have a little project which I’m coding in AS3 Flash… But I needed mysql and php for score recording…  
My game has 3 levels, and it will show the user these 3 levels scores every time he/she logins… (Example = Your best scores : level1-\>20 level2-\>45 level3-\>62)

Now the score table has, one id column for recognizing the user, and the two others for game\_type and score…  
the table is like this :  
id | score | game\_type  
1 12 0  
1 23 0  
1 32 1  
1 46 0  
1 55 1  
1 78 1  
1 18 0  
1 71 2  
1 47 2  
1 13 2

What I want to do is, with one query, get every game\_type’s lowest score…

For the above example : type0-\>12 type1 -\> 32 type2-\> 13

My query is this:  
SELECT score  
FROM ScoreTable  
WHERE id = $userID AND game\_type  
IN (SELECT game\_type FROM ScoreTable)  
ORDER BY score ASC LIMIT 3

But I can not get the result I want…  
Any ideas?

Thanks in advance…
