Question: I have 2 tables: one table with many rows and a second table with one row. The tables have no fields in common. Is it possible to combine them into one table with many rows?

I've checked UNION, [but MSDN says](https://learn.microsoft.com/en-us/sql/t-sql/language-elements/set-operators-union-transact-sql):

> 
> The following are basic rules for combining the result sets of two queries by using UNION:
> 
> 
> * Each SELECT statement within UNION must have the same number of columns.
> * The columns must also have similar data types.
> * The columns in each SELECT statement must also be in the same order.
> 
> 
> 

Example
-------

This is what my tables look like right now:

```
      Table 1                            Table 2

Column1    Column2        Column4    Column5    Column3
-------    -------        -------    -------    -------
A          1                 E          10         a
B          2                                    
C          3                                    
D          4                                    

```

And this is what I'm trying to achieve as a result:

```
            CONSOLIDATED_Table 3                   
Column1    Column2  Column3    Column4    Column5
-------    -------  -------    -------    -------
A          1         E          10         a
B          2         E          10         a
C          3         E          10         a
D          4         E          10         a

```

Answer: 
Although you didn't mentioned the database name, this following query logic will be applicable for all databases-

```
SELECT * 
FROM your_table
WHERE idMaster NOT IN (10,11)
OR (idMaster = 10 AND idList = 45)
OR (idMaster = 11 AND idList = 98)

```
You can indeed do this with a (nested) `case`. Hopefully this helps you understand better.

```
case idMaster
    when 10 then case idList when 45 then 1 end
    when 11 then case idList when 98 then 1 end
    else 1
end = 1

```

This might be the best though:

```
not (idList = 10 and idList <> 45 or idList = 11 and idList <> 98)

```

Overall it's usually beneficial to avoid repeating that list of values in multiple places. Both of these avoid the need to keep things in sync when changes come.