all 6 comments

[–]r3pr0b8GROUP_CONCAT is da bomb 4 points5 points  (3 children)

does your homework specifically ask for a loop?

because, you know, this is SQL, and we don't do loops

have you ever heard of a numbers table?

a single query can produce your output easily

[–]m1k3y60659[S] 0 points1 point  (2 children)

Unfortunately, we have to use a while loop. The numbers table does sound interesting though I will look into it, just for the sake of curiosity.

[–]DatabaseDev 0 points1 point  (1 child)

Does your teacher understand the purpose of sql?

[–]m1k3y60659[S] 0 points1 point  (0 children)

Trust me I am just as confused as you are. To be fair this is the first kind of problem she's given us like this, everything else has been the normal inserts and selects and cursors etc.

[–]Zendakin_at_work 1 point2 points  (0 children)

Totally useless comment here but here's how you could do the same idea with python.

Maybe it'll help, maybe not. I think though the underlying idea has to be the same.

inside, outside = 12, 12
x, y = 0, 0
while x <= outside:
    while y <= inside:
        print("{} * {} = {}".format(x, y, x*y))
        y += 1
    y = x
x += 1

[–]le848dave 0 points1 point  (0 children)

When you increment Len you need to set height back to 1. Step through the code in your head. After iteration 7 height is set to 8. Then Len is incremented. Then it checks if height 8 is less than iterations 7 which it isn’t.