mardi 24 novembre 2015

SQLite selecting/filtering a Table and limit the output

I'm doing a SQL project for school I have this table:

 name        price_gold  price_euros  role        universe
----------  ----------  -----------  ----------  -----------------
Sylvanas    10,000      9,99         Specialist  World of Warcraft
The Lost V  10,000      9,99         Specialist  The Lost Vikings
Azmodan     10,000      9,99         Specialist  Diablo
Zagara      7,000       8,49         Specialist  Starcraft
Murky       7,000       8,49         Specialist  World of Warcraft
Abathur     10,000      9,99         Specialist  Starcraft
Gazlowe     4,000       6,49         Specialist  World of Warcraft
Nazeebo     10,000      9,99         Specialist  Diablo
Sgt. Hamme  7,000       8,49         Specialist  Starcraft
Artanis     10,000      9,99         Warrior     Starcraft
Rexxar      10,000      9,99         Warrior     World of Warcraft
Leoric      10,000      9,99         Warrior     Diablo
Johanna     10,000      9,99         Warrior     Diablo
Anub'arak   4,000       6,49         Warrior     World of Warcraft
Chen        7,000       8,49         Warrior     World of Warcraft
Arthas      7,000       8,49         Warrior     World of Warcraft
Diablo      7,000       8,49         Warrior     Diablo
E.T.C.      2,000       3,99         Warrior     World of Warcraft
Muradin     2,000       3,99         Warrior     World of Warcraft
Sonya       4,000       6,49         Warrior     Diablo
Stitches    7,000       8,49         Warrior     World of Warcraft
Tyrael      4,000       6,49         Warrior     Diablo
Cho                                  Warrior     World of Warcraft
Gall                                 Assassin    World of Warcraft
The Butche  10,000      9,99         Assassin    Diablo
Kael'thas   10,000      9,99         Assassin    World of Warcraft
Thrall      10,000      9,99         Assassin    World of Warcraft
Jaina       4,000       6,49         Assassin    World of Warcraft
Tychus      4,000       6,49         Assassin    Starcraft
Falstad     7,000       8,49         Assassin    World of Warcraft
Illidan     4,000       6,49         Assassin    World of Warcraft

And I want to query a select of 5 different roles and 5 random names i.e. this:

name        role
----------  ---------
Sylvanas    Specialis
The Lost V  Specialis
Azmodan     Specialis
Zagara      Specialis
Murky       Specialis
Johanna     Warrior
Anub'arak   Warrior
Chen        Warrior
Arthas      Warrior
Stitches    Warrior
The Butche  Assassin
Kael'thas   Assassin
Thrall      Assassin
Jaina       Assassin
Tychus      Assassin
Lt. Morale  Support
Kharazim    Support
Reghar      Support
Brightwing  Support

I tried using Limit but that only gives the first 5 elements of the table.

What to do?

Aucun commentaire:

Enregistrer un commentaire