I want to create a loop in mysql.
I have 2 tables, and I want to select all data from table A and result from table A for get data in table B.
For example CASE:
SELECT * FROM table_A;
Result:
Column_1 Column 2
-------------------
A B
A1 B1
ABC CDS
Query:
SELECT *
FROM table_B
WHERE column = (...result from table_A....)
I want show all data using loop in mysql
CREATE PROCEDURE ROWPERROW()
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE i INT DEFAULT 0;
SELECT * FROM table_A ;
SET i=0;
WHILE i<n DO
............TABLE_B
END WHILE;
END;
;;
you could use an INNER JOIN for obtain the result wit a single query
SELECT b.*
FROM table_B b
INNER JOIN table_A a ON a.column_1 = b.col1 and a.column_2 = b.col2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.