Skip to content

Instantly share code, notes, and snippets.

@hidayat365
Created July 8, 2012 13:35
Show Gist options
  • Save hidayat365/3070971 to your computer and use it in GitHub Desktop.
Save hidayat365/3070971 to your computer and use it in GitHub Desktop.
Bang Totok Ganteng
D:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use information_schema;
Database changed
mysql> SELECT @nomor:=0;
+-----------+
| @nomor:=0 |
+-----------+
| 0 |
+-----------+
1 row in set (0.00 sec)
mysql> SELECT @nomor:=@nomor+1 AS baris
-> , CASE WHEN @nomor%3=0 AND @nomor%5=0 THEN 'Saya Ganteng'
-> WHEN @nomor%3=0 THEN 'Saya'
-> WHEN @nomor%5=0 THEN 'Ganteng'
-> ELSE @nomor END hasil
-> FROM TABLES LIMIT 100;
+-------+--------------+
| baris | hasil |
+-------+--------------+
| 1 | 1 |
| 2 | 2 |
| 3 | Saya |
| 4 | 4 |
| 5 | Ganteng |
| 6 | Saya |
| 7 | 7 |
| 8 | 8 |
| 9 | Saya |
| 10 | Ganteng |
| 11 | 11 |
| 12 | Saya |
| 13 | 13 |
| 14 | 14 |
| 15 | Saya Ganteng |
| 16 | 16 |
| 17 | 17 |
| 18 | Saya |
| 19 | 19 |
| 20 | Ganteng |
| 21 | Saya |
| 22 | 22 |
| 23 | 23 |
| 24 | Saya |
| 25 | Ganteng |
| 26 | 26 |
| 27 | Saya |
| 28 | 28 |
| 29 | 29 |
| 30 | Saya Ganteng |
| 31 | 31 |
| 32 | 32 |
| 33 | Saya |
| 34 | 34 |
| 35 | Ganteng |
| 36 | Saya |
| 37 | 37 |
| 38 | 38 |
| 39 | Saya |
| 40 | Ganteng |
| 41 | 41 |
| 42 | Saya |
| 43 | 43 |
| 44 | 44 |
| 45 | Saya Ganteng |
| 46 | 46 |
| 47 | 47 |
| 48 | Saya |
| 49 | 49 |
| 50 | Ganteng |
| 51 | Saya |
| 52 | 52 |
| 53 | 53 |
| 54 | Saya |
| 55 | Ganteng |
| 56 | 56 |
| 57 | Saya |
| 58 | 58 |
| 59 | 59 |
| 60 | Saya Ganteng |
| 61 | 61 |
| 62 | 62 |
| 63 | Saya |
| 64 | 64 |
| 65 | Ganteng |
| 66 | Saya |
| 67 | 67 |
| 68 | 68 |
| 69 | Saya |
| 70 | Ganteng |
| 71 | 71 |
| 72 | Saya |
| 73 | 73 |
| 74 | 74 |
| 75 | Saya Ganteng |
| 76 | 76 |
| 77 | 77 |
| 78 | Saya |
| 79 | 79 |
| 80 | Ganteng |
| 81 | Saya |
| 82 | 82 |
| 83 | 83 |
| 84 | Saya |
| 85 | Ganteng |
| 86 | 86 |
| 87 | Saya |
| 88 | 88 |
| 89 | 89 |
| 90 | Saya Ganteng |
| 91 | 91 |
| 92 | 92 |
| 93 | Saya |
| 94 | 94 |
| 95 | Ganteng |
| 96 | Saya |
| 97 | 97 |
| 98 | 98 |
| 99 | Saya |
| 100 | Ganteng |
+-------+--------------+
100 rows in set (0.04 sec)
mysql>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment