Skip to content
Advertisement

SQL: Two select statements in one query

I want to select information from two SQL tables within one query, the information is unrelated though, so no potential joints exist.

An example could be the following setup.

tblMadrid

tblBarcelona

I want to have a query that gives me the following:

I tried to follow this logic: Multiple select statements in Single query but the following code did not work:

Any advice on this one? Thanks Info: The football stuff is just a simplifying example. In reality it is not possible to put both tables into one and have a new “team” column. The two tables have completely different structures, but I need something that matches the characteristics of this example.

Advertisement

Answer

You can do something like this:

See, for example: https://dev.mysql.com/doc/refman/5.0/en/union.html

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement