This is a discussion on Loop in Mysql within the Database Support forums, part of the Web Development category; hi techies, The following code will work upto 100 loops.. You may add one more join will get 1000 loops... ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| hi techies, The following code will work upto 100 loops.. You may add one more join will get 1000 loops... Code: SET @string:='one,tow,three,four,five,six,seven,eight,nine,ten';
SET @row:=0;
SET @length:=LENGTH(@string)-LENGTH(REPLACE(@string,',',''))+1;
SET @from_clause:=CONCAT('SELECT 1 ',REPEAT(' UNION ALL SELECT 1 ',9));
SET @sql:=CONCAT("
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(@string,',',@row:=@row+1),',',-1) AS numbers
FROM (",@from_clause,")a JOIN (",@from_clause," )b LIMIT ",@length);
PREPARE st FROM @sql;
EXECUTE st; Code: numbers ---------- one tow three four five six seven eight nine ten
__________________ -Murali.. |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can i do loop testing manually? | sundarraja | Software Testing | 1 | 07-25-2007 01:02 AM |
| Javaa:Tutorial - The Loop | pranky | Java Programming | 0 | 02-24-2007 12:58 AM |