Re: How Do I Cycle Through a Column in MySQL?
Posted by:
Lena Oan
Date: December 15, 2022 04:04AM
I think you want something like this:
DECLARE col_names CURSOR FOR
SELECT column_name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'tbl_name'
ORDER BY ordinal_position;
select FOUND_ROWS() into num_rows;
SET i = 1;
the_loop: LOOP
IF i > num_rows THEN
CLOSE col_names;
LEAVE the_loop;
END IF;
FETCH col_names
INTO col_name;
//do whatever else you need to do with the col name
SET i = i + 1;
END LOOP the_loop;
Subject
Written By
Posted
November 10, 2022 03:51PM
Re: How Do I Cycle Through a Column in MySQL?
December 15, 2022 04:04AM
December 30, 2022 12:58PM
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.