MySQL Forums
Forum List  »  Oracle

Re: Funcion INSTR
Posted by: Fabio Castillo
Date: August 18, 2009 10:34AM

Thank you Dmitry Tolpeko for you help

Follow your example if i have this data

mysql> select * from t2;
+---------+
| c1 |
+---------+
| 1,2,3 |
| 1 |
| 2 |
| 1,1 |
| 1,2 |
| 1,3 |
| 1,1,1 |
| 1,1,3 |
| 1,1,4 |
| 1,2,2,1 |
| 1,2,2,2 |
| 1,2,8,1 |

I need to know the number of occurrences of ',' in each row
Result of the query would be as follows:

+---------++-----------+
| c1 |occurre |
+---------+------------+
| 1,2,3 |2
| 1 |0
| 2 |0
| 1,1 |1
| 1,2 |1
| 1,3 |1
| 1,1,1 |2
| 1,1,3 |2
| 1,1,4 |2
| 1,2,2,1 |3
| 1,2,2,2 |3
| 1,2,8,1 |3

in oracle is

SELECT c1, INSTR(C1,',',1,2) FROM t2;

in Mysql is?
help me please

Options: ReplyQuote


Subject
Views
Written By
Posted
9534
August 16, 2009 12:00PM
6959
August 17, 2009 02:38PM
Re: Funcion INSTR
4051
August 18, 2009 10:34AM
3869
August 18, 2009 12:58PM
4208
August 18, 2009 04:32PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.