FIELD Returns the index position of a value in a list of values
SELECT FIELD("l", "v", "l", "r");
SELECT FIELD("p", "b", "c");
SELECT FIELD(5, 0, 1, 2, 3, 4, 5);
SELECT FIELD(5, 0, 1, 5, 3, 4, 5);
'ramesh','vlr','praveen','lachu
MariaDB [vlrinst]> select field('vlr',
-> 'ramesh','vlr','praveen','lachu');
+------------------------------------------------+
| field('vlr',
'ramesh','vlr','praveen','lachu') |
+------------------------------------------------+
| 2 |
+------------------------------------------------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> select field(22,33,55,66,22,44,22);
+-----------------------------+
| field(22,33,55,66,22,44,22) |
+-----------------------------+
| 4 |
+-----------------------------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> select field(22,33,55,66,44);
+-----------------------+
| field(22,33,55,66,44) |
+-----------------------+
| 0 |
+-----------------------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> select field('kphb',loc) from emp;;
+-------------------+
| field('kphb',loc) |
+-------------------+
| 1 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
+-------------------+
9 rows in set (0.001 sec)
ERROR: No query specified
MariaDB [vlrinst]> select * from emp;
+----+---------+-----------+------+-------+
| id | name | loc | age | sal |
+----+---------+-----------+------+-------+
| 10 | venkat | kphb | 35 | 30000 |
| 11 | praveen | pune | 28 | 35000 |
| 12 | mounika | hyderabad | 22 | 39000 |
| 13 | revathi | jntu | 26 | 20000 |
| 14 | anji | gutta | 28 | 20000 |
| 15 | harika | lb nagar | 26 | 30100 |
| 16 | praveen | jntu | 33 | 100 |
| 17 | pandu | munipeda | 35 | 30300 |
| 18 | pandu | pune | 23 | 39300 |
+----+---------+-----------+------+-------+
9 rows in set (0.000 sec)
MariaDB [vlrinst]> select field('pune',loc) from emp;;
+-------------------+
| field('pune',loc) |
+-------------------+
| 0 |
| 1 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 1 |
+-------------------+
9 rows in set (0.000 sec)
ERROR: No query specified
MariaDB [vlrinst]> select field('pune',loc,name) from emp;;
+------------------------+
| field('pune',loc,name) |
+------------------------+
| 0 |
| 1 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 1 |
+------------------------+
9 rows in set (0.001 sec)
ERROR: No query specified
MariaDB [vlrinst]> select field('pune',loc),sal from emp;;
+-------------------+-------+
| field('pune',loc) | sal |
+-------------------+-------+
| 0 | 30000 |
| 1 | 35000 |
| 0 | 39000 |
| 0 | 20000 |
| 0 | 20000 |
| 0 | 30100 |
| 0 | 100 |
| 0 | 30300 |
| 1 | 39300 |
+-------------------+-------+
9 rows in set (0.001 sec)
ERROR: No query specified
MariaDB [vlrinst]>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.