MySQL Forums
Forum List  »  Oracle

Re: Funcion INSTR
Posted by: Dmitry Tolpeko
Date: August 17, 2009 02:38PM

Hi Fabio,

I do not speak your language, so I tried to convert SQL based on your samples :)

SELECT INSTR('1,2,3',',',1,2) FROM CONTENIDO;
->
SELECT LOCATE(',', '1,2,3', LOCATE(',', '1,2,3')+1) FROM CONTENIDO;

The first locate() will return the first occurrence, the second locate() will return the second occurrence.


mysql> create table t2 (c1 varchar(100));
Query OK, 0 rows affected (0.26 sec)

mysql> insert into t2 values ('1,2,3');
Query OK, 1 row affected (0.07 sec)

mysql> SELECT LOCATE(',', '1,2,3', LOCATE(',', '1,2,3')+1) FROM t2;
+----------------------------------------------+
| LOCATE(',', '1,2,3', LOCATE(',', '1,2,3')+1) |
+----------------------------------------------+
|                                            4 |
+----------------------------------------------+
1 row in set (0.14 sec)

It is more complicated if you need to find 7th occurrence :)

Kind regards, Dmitry Tolpeko

--
SQLWays - Convert Oracle PL/SQL stored procedures, packages, triggers and queries to MySQL
http://www.ispirer.com/products/mysql-migration

Options: ReplyQuote


Subject
Views
Written By
Posted
9509
August 16, 2009 12:00PM
Re: Funcion INSTR
6897
August 17, 2009 02:38PM
4045
August 18, 2009 10:34AM
3856
August 18, 2009 12:58PM
4199
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.