SQLite Forum

Multiply table select with table identification
Login
> SELECT * FROM TABLE1, TABLE2; i'd get result ...

Those are not the results you'd get from that query. You'd get a number of results equal to the number of rows from table 1 multiplied by the number of rows from table 2:

```
sqlite> create temp table x(y);
sqlite> create temp table z(a);
sqlite> insert into x(y) values(1),(2),(3);
sqlite> insert into z(a) values(4),(5),(6);
sqlite> select * from x, z;
1,4
1,5
1,6
2,4
2,5
2,6
3,4
3,5
3,6
```


What you want is something like:

```
sqlite> select *, 'table x' from x union select *, 'table z' from z;
1,'table x'
2,'table x'
3,'table x'
4,'table z'
5,'table z'
6,'table z'
```