Triangular pattern example The above pattern is for p(5). How to write a query to print the pattern P(n) (where n is Integer defining the number of rows) using MySQL without using Stored Procedure. I had one code example for MS SQL Server i.e.
DECLARE @i INT = 20
WHILE (@i > 0)
BEGIN
PRINT REPLICATE('* ', @i)
SET @i = @i - 1
END
SET @NUMBER = 21;
SELECT REPEAT('* ', @NUMBER := @NUMBER - 1)
FROM information_schema.tables LIMIT 20;
OR
SET @NUMBER = 21;
SELECT REPEAT('* ', @NUMBER := @NUMBER - 1)
FROM information_schema.tables WHERE @NUMBER > 1;
SET @NUMBER = 21;
SELECT REPEAT('* ', @NUMBER := @NUMBER - 1)
FROM information_schema.tables;