Preface: this isn't homework - I am learning SQL.
I was given the problem to make a multiplication chart.
Here's my solution:
create table x (x int)
create table y ([1] int, [2] int, [3] int, [4] int, [5] int, [6] int, [7] int, [8] int, [9] int, [10] int)
insert into x (x)
values ('1')
insert into x (x)
values ('2')
insert into x (x)
values ('3')
insert into x (x)
values ('4')
insert into x (x)
values ('5')
insert into x (x)
values ('6')
insert into x (x)
values ('7')
insert into x (x)
values ('8')
insert into x (x)
values ('9')
insert into x (x)
values ('10')
insert into y ([1], [2], [3], [4], [5], [6], [7], [8], [9], [10])
values ('1', '2', '3', '4', '5', '6', '7', '8', '9', '10')
select * from x
select * from y
select x * y.[1] as [1's table],
x * y.[2] as [2's table],
x * y.[3] as [3's table],
x * y.[4] as [4's table],
x * y.[5] as [5's table],
x * y.[6] as [6's table],
x * y.[7] as [7's table],
x * y.[8] as [8's table],
x * y.[9] as [9's table],
x * y.[10] as [10's table]
from x cross join y
This all seems very messy and typing it out was a bit tedious. I wanted to try to do it without having to specify each column in the y table as so:
select x * y from x, y
But this didn't work as SQL is asking for a column. But I want it to perform multiplication across all columns. How do I make my times table more efficiently?