MySQL [pokemon]> SELECT * FROM (SELECT P.Name, A.* FROM Pokemon P, Attributes A WHERE P.PokedexId = A.PokedexID ) x, Species s WHERE s.pokedexId = x.pokedexId and s.pokedexId < 10; +------------+-----------+--------+--------+----------------+-----------+--------+-------------+ | Name | PokedexID | Height | Weight | BaseExperience | PokedexID | TypeID | Genus | +------------+-----------+--------+--------+----------------+-----------+--------+-------------+ | Bulbasaur | 1 | 7 | 69 | 64 | 1 | 12 | Seed | | Ivysaur | 2 | 10 | 130 | 141 | 2 | 12 | Seed | | Venusaur | 3 | 20 | 1000 | 208 | 3 | 12 | Seed | | Charmander | 4 | 6 | 85 | 65 | 4 | 10 | Lizard | | Charmeleon | 5 | 11 | 190 | 142 | 5 | 10 | Flame | | Charizard | 6 | 17 | 905 | 209 | 6 | 10 | Flame | | Squirtle | 7 | 5 | 90 | 66 | 7 | 11 | Tiny Turtle | | Wartortle | 8 | 10 | 225 | 143 | 8 | 11 | Turtle | | Blastoise | 9 | 16 | 855 | 210 | 9 | 11 | Shellfish | +------------+-----------+--------+--------+----------------+-----------+--------+-------------+ 9 rows in set (0.01 sec) MySQL [pokemon]> MySQL [pokemon]> MySQL [pokemon]> MySQL [pokemon]> SELECT BaseExperience -> FROM Attributes a, Pokemon p -> WHERE a.PokedexId = p.PokedexId and -> p.Name = 'Pikachu' -> ; +----------------+ | BaseExperience | +----------------+ | 82 | +----------------+ 1 row in set (0.01 sec) MySQL [pokemon]> MySQL [pokemon]> SELECT * -> FROM Attributes a, Pokemon p -> WHERE a.PokedexId = p.PokedexId and -> p.Name = 'Pikachu' -> ; +-----------+--------+--------+----------------+-----------+---------+ | PokedexID | Height | Weight | BaseExperience | PokedexID | Name | +-----------+--------+--------+----------------+-----------+---------+ | 25 | 4 | 60 | 82 | 25 | Pikachu | +-----------+--------+--------+----------------+-----------+---------+ 1 row in set (0.00 sec) MySQL [pokemon]> MySQL [pokemon]> SELECT * -> FROM Pokemon -> WHERE Name = 'Pikachu' -> ; +-----------+---------+ | PokedexID | Name | +-----------+---------+ | 25 | Pikachu | +-----------+---------+ 1 row in set (0.01 sec) MySQL [pokemon]> MySQL [pokemon]> SELECT PokeDexId -> FROM Pokemon -> WHERE Name = 'Pikachu' -> ; +-----------+ | PokeDexId | +-----------+ | 25 | +-----------+ 1 row in set (0.00 sec) MySQL [pokemon]> MySQL [pokemon]> SELECT BaseExperience -> FROM Attributes -> WHERE PokedexID = (SELECT PokeDexId -> FROM Pokemon -> WHERE Name = 'Pikachu') -> ; +----------------+ | BaseExperience | +----------------+ | 82 | +----------------+ 1 row in set (0.00 sec) MySQL [pokemon]> MySQL [pokemon]> SELECT BaseExperience -> FROM Attributes -> WHERE PokedexID = (SELECT PokeDexId -> FROM Pokemon -> WHERE Name = 'Pikachu')+1 -> ; +----------------+ | BaseExperience | +----------------+ | 122 | +----------------+ 1 row in set (0.00 sec) MySQL [pokemon]> select * from Attributes where pokedexid=26; +-----------+--------+--------+----------------+ | PokedexID | Height | Weight | BaseExperience | +-----------+--------+--------+----------------+ | 26 | 8 | 300 | 122 | +-----------+--------+--------+----------------+ 1 row in set (0.00 sec) MySQL [pokemon]> SELECT * -> from Pokemon where PokedexId IN (20, 21, 340); +-----------+----------+ | PokedexID | Name | +-----------+----------+ | 20 | Raticate | | 21 | Spearow | | 340 | Whiscash | +-----------+----------+ 3 rows in set (0.00 sec) MySQL [pokemon]> SELECT a.PokedexID -> FROM Attributes a, Species s, Types t -> WHERE s.typeId = t.typeId and t.type = 'Fire' and -> s.PokedexId = a.PokedexID and -> a.BaseExperience < 100 -> ; +-----------+ | PokedexID | +-----------+ | 4 | | 37 | | 58 | | 155 | | 218 | | 255 | | 322 | | 390 | | 498 | | 513 | | 554 | +-----------+ 11 rows in set (0.00 sec) MySQL [pokemon]> SELECT Name -> FROM Pokemon -> WHERE PokeDexId = ( SELECT a.PokedexID -> FROM Attributes a, Species s, Types t -> WHERE s.typeId = t.typeId and t.type = 'Fire' and -> s.PokedexId = a.PokedexID and -> a.BaseExperience < 100 -> ) -> ; ERROR 1242 (21000): Subquery returns more than 1 row MySQL [pokemon]> SELECT Name -> FROM Pokemon -> WHERE PokeDexId IN ( SELECT a.PokedexID -> FROM Attributes a, Species s, Types t -> WHERE s.typeId = t.typeId and t.type = 'Fire' and -> s.PokedexId = a.PokedexID and -> a.BaseExperience < 100 -> ) -> ; +------------+ | Name | +------------+ | Charmander | | Chimchar | | Cyndaquil | | Darumaka | | Growlithe | | Numel | | Pansear | | Slugma | | Tepig | | Torchic | | Vulpix | +------------+ 11 rows in set (0.01 sec) MySQL [pokemon]> MySQL [pokemon]> SELECT * -> FROM Pokemon -> WHERE PokeDexId IN ( SELECT a.PokedexID -> FROM Attributes a, Species s, Types t -> WHERE s.typeId = t.typeId and t.type = 'Fire' and -> s.PokedexId = a.PokedexID and -> a.BaseExperience < 100 -> ) -> ; +-----------+------------+ | PokedexID | Name | +-----------+------------+ | 4 | Charmander | | 390 | Chimchar | | 155 | Cyndaquil | | 554 | Darumaka | | 58 | Growlithe | | 322 | Numel | | 513 | Pansear | | 218 | Slugma | | 498 | Tepig | | 255 | Torchic | | 37 | Vulpix | +-----------+------------+ 11 rows in set (0.00 sec) MySQL [pokemon]> SELECT * -> FROM Attributes a -> WHERE Exists (SELECT BaseExperience -> FROM Attributes a1, Species s, Types t -> WHERE s.typeId = t.typeId and t.type = 'Fire' -> and a1.PokeDexId = s.PokeDexId and -> a.PokedexId <> a1.PokeDexId and -> a.BaseExperience = a1.BaseExperience -> ) -> ; +-----------+--------+--------+----------------+ | PokedexID | Height | Weight | BaseExperience | +-----------+--------+--------+----------------+ | 4 | 6 | 85 | 65 | | 5 | 11 | 190 | 142 | | 6 | 17 | 905 | 209 | | 30 | 8 | 200 | 117 | | 37 | 6 | 99 | 63 | | 43 | 5 | 54 | 78 | | 55 | 17 | 766 | 174 | | 67 | 15 | 705 | 146 | | 82 | 10 | 600 | 161 | | 115 | 22 | 800 | 175 | | 139 | 10 | 350 | 199 | | 141 | 13 | 405 | 199 | | 143 | 21 | 4600 | 154 | | 144 | 17 | 554 | 215 | | 146 | 20 | 600 | 217 | | 150 | 20 | 1220 | 220 | | 155 | 5 | 79 | 65 | | 156 | 9 | 190 | 142 | | 157 | 17 | 795 | 209 | | 180 | 8 | 133 | 117 | | 192 | 8 | 85 | 146 | | 209 | 6 | 78 | 63 | | 210 | 14 | 487 | 178 | | 220 | 4 | 65 | 78 | | 223 | 6 | 120 | 78 | | 226 | 21 | 2200 | 168 | | 227 | 17 | 505 | 168 | | 236 | 7 | 210 | 91 | | 244 | 21 | 1980 | 217 | | 245 | 20 | 1870 | 215 | | 249 | 52 | 2160 | 220 | | 252 | 5 | 50 | 65 | | 255 | 4 | 25 | 65 | | 256 | 9 | 195 | 142 | | 257 | 19 | 520 | 209 | | 258 | 4 | 76 | 65 | | 267 | 10 | 284 | 161 | | 269 | 12 | 316 | 161 | | 283 | 5 | 17 | 63 | | 285 | 4 | 45 | 65 | | 290 | 5 | 55 | 65 | | 300 | 6 | 110 | 65 | | 305 | 9 | 1200 | 152 | | 307 | 6 | 112 | 91 | | 310 | 15 | 402 | 168 | | 313 | 7 | 177 | 146 | | 314 | 6 | 177 | 146 | | 315 | 3 | 20 | 152 | | 317 | 17 | 800 | 168 | | 318 | 8 | 208 | 88 | | 319 | 18 | 888 | 175 | | 342 | 11 | 328 | 161 | | 346 | 15 | 604 | 199 | | 348 | 15 | 682 | 199 | | 350 | 62 | 1620 | 213 | | 357 | 20 | 1000 | 169 | | 359 | 12 | 470 | 174 | | 365 | 14 | 1506 | 192 | | 366 | 4 | 525 | 142 | | 367 | 17 | 270 | 178 | | 368 | 18 | 226 | 178 | | 369 | 10 | 234 | 198 | | 377 | 17 | 2300 | 217 | | 379 | 19 | 2050 | 215 | | 384 | 70 | 2065 | 220 | | 385 | 3 | 11 | 215 | | 386 | 17 | 608 | 215 | | 390 | 5 | 62 | 65 | | 391 | 9 | 220 | 142 | | 392 | 12 | 550 | 209 | | 404 | 9 | 305 | 117 | | 409 | 16 | 1025 | 199 | | 411 | 13 | 1495 | 199 | | 415 | 3 | 55 | 63 | | 419 | 11 | 335 | 178 | | 428 | 12 | 333 | 178 | | 435 | 10 | 380 | 209 | | 439 | 6 | 130 | 78 | | 442 | 10 | 1080 | 168 | | 450 | 20 | 3000 | 198 | | 461 | 11 | 340 | 199 | | 464 | 24 | 2828 | 217 | | 466 | 18 | 1386 | 199 | | 468 | 15 | 380 | 220 | | 469 | 19 | 515 | 198 | | 472 | 20 | 425 | 192 | | 476 | 14 | 3400 | 198 | | 483 | 54 | 6830 | 220 | | 484 | 42 | 3360 | 220 | | 486 | 37 | 4200 | 220 | | 487 | 45 | 7500 | 220 | | 490 | 3 | 14 | 215 | | 495 | 6 | 81 | 28 | | 497 | 33 | 630 | 238 | | 501 | 5 | 59 | 28 | | 503 | 15 | 946 | 238 | | 511 | 6 | 105 | 63 | | 512 | 11 | 305 | 174 | | 513 | 6 | 110 | 63 | | 515 | 6 | 135 | 63 | | 516 | 10 | 290 | 174 | | 521 | 12 | 290 | 215 | | 523 | 16 | 795 | 174 | | 527 | 4 | 21 | 63 | | 530 | 7 | 404 | 178 | | 533 | 12 | 400 | 142 | | 547 | 7 | 66 | 168 | | 549 | 11 | 163 | 168 | | 550 | 10 | 180 | 161 | | 554 | 6 | 375 | 63 | | 556 | 10 | 280 | 161 | | 557 | 3 | 145 | 65 | | 563 | 17 | 765 | 169 | | 588 | 5 | 59 | 63 | | 593 | 22 | 1350 | 168 | | 600 | 6 | 510 | 154 | | 603 | 12 | 220 | 142 | | 623 | 28 | 3300 | 169 | | 632 | 3 | 330 | 169 | +-----------+--------+--------+----------------+ 119 rows in set (0.03 sec) MySQL [pokemon]> exir -> ; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'exir' at line 1 MySQL [pokemon]> exit