Jake Marmak Jake Marmak - 1 year ago 69
SQL Question

Consolidating two tables with repeating results

I am having a problem how to query two tables as shown

Table 1

id module
1 Part1
2 Part2
3 Part3
4 Part4

Table 2

id Town
1 Town 1
2 Town 2
3 Town 4

Resulting query

Module Town
Part1 Town 1
Part2 Town 1
Part3 Town 1
Part4 Town 1
Part1 Town 2
Part2 Town 2
Part3 Town 2
Part4 Town 2
Part1 Town 4
Part2 Town 4
Part3 Town 4
Part4 Town 4

I tried using union but got a different result. Hoping for your kind solution to this problem of mine...

Answer Source

When you want implement a cartesian product you must use CROSS JOIN statement

Try this:

SELECT table1.module, table2.town
FROM table1

You can see here about JOINs operation in SQLite

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download