I have a table with a list of names in it as below

```
+----------+
| CLI_NAME |
+----------+
| A        |
| B        |
| C        |
| D        |
| E        |
+----------+

```

I'd like to loop through this something like 

```
for each value in CLI_NAME do
{
   bla bla
}

```

For each value in the table CLI\_NAMES, I'd like to loop through and execute the below.

The value selected from the table above needs to go in as a parameter to T\_NAME such as T\_NAME = "abc" in the query below

```
INSERT INTO TABLE_2(DATE, O_WT)
SELECT 
    F_DATE,
    CASE 
        WHEN
            SUM(
                CASE
                    WHEN
                        F_NAME like 'ty%asd%'
                    THEN
                        F_PKEY
                END
            ) = 1 THEN 1
        WHEN
            SUM(
                CASE
                    WHEN
                        F_NAME like 'ty%asd%'
                    THEN
                        F_PKEY
                END

            ) = 2 THEN 2               
        WHEN
            SUM(
                CASE
                    WHEN
                        F_NAME like 'ty%asd%'
                    THEN
                        F_PKEY
                END
            ) BETWEEN 3 AND 5 THEN  3 
        WHEN
            SUM(
                CASE
                       WHEN
                        F_NAME like 'ty%asd%'
                    THEN
                        F_PKEY
                END

            ) > 5 THEN 5                          
            ELSE 0 
    END AS O_WT
FROM
    TABLE_1 
WHERE 
    F_NAME IN (
        SELECT I_NAME from I_WD WHERE I_I_ID IN (
            SELECT I_MAP_ID FROM T_T_MAP where T_MAP_ID = (
                SELECT T_ID FROM TWD WHERE T_NAME = 'abc'
            )
        )
    ) 
    AND F_DATE between '2015-05-01' and '2015-06-01' 
    AND F_NAME LIKE 'ty%pr%' 
        GROUP BY F_DATE

```

How could I loop through & do this please?