Advertisement
Guest User

Untitled

a guest
Sep 19th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. select
  2. @first:=SUBSTRING_INDEX(combinations,',',1) as first,
  3. @second:=substring_index(SUBSTRING_INDEX(combinations,',',2), ',', -1) as second,
  4. @third:=substring_index(SUBSTRING_INDEX(combinations,',',3), ',', -1) as third,
  5. @forth:=substring_index(SUBSTRING_INDEX(combinations,',',4), ',', -1) as forth,
  6. @fifth:=substring_index(SUBSTRING_INDEX(combinations,',',5), ',', -1) as fifth,
  7. @sixth:=SUBSTRING_INDEX(combinations,',',-1) as sixth,
  8. @suma:=@first+@second+@third+@forth+@fifth+@sixth as suma
  9. from All_combinations limit 10;
  10.  
  11. +-------+--------+-------+-------+-------+-------+------+
  12. | first | second | third | forth | fifth | sixth | suma |
  13. +-------+--------+-------+-------+-------+-------+------+
  14. | 1 | 2 | 3 | 4 | 5 | 6 | 21 |
  15. | 1 | 2 | 3 | 4 | 5 | 7 | 22 |
  16. | 1 | 2 | 3 | 4 | 5 | 8 | 23 |
  17. | 1 | 2 | 3 | 4 | 5 | 9 | 24 |
  18. | 1 | 2 | 3 | 4 | 5 | 10 | 25 |
  19. | 1 | 2 | 3 | 4 | 5 | 11 | 26 |
  20. | 1 | 2 | 3 | 4 | 5 | 12 | 27 |
  21. | 1 | 2 | 3 | 4 | 5 | 13 | 28 |
  22. | 1 | 2 | 3 | 4 | 5 | 14 | 29 |
  23. | 1 | 2 | 3 | 4 | 5 | 15 | 30 |
  24. +-------+--------+-------+-------+-------+-------+------+
  25. 10 rows in set (0.00 sec)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement