Using SQL Server, I need to return the entire row from any table containing a “value” in the “File Name” column (the column that contains each of the tables), but the tables do not have the same number of columns, and each table has unique columns with its own specific data types (The only Name / Type column that they have is the Filename column, which I need to check for "value").
Ideally, I could do something like: SELECT * FROM Table1, Table2, Table3, Table4, Table5 WHERE Filename = 'someValue' Since all tables have the same column name for the file name.
I tried using Union, but it has problems, since the number of columns and table data types does not align. I also tried every JOIN combination I could find.
I am sure that this can be done with IF EXISTS, but it will be many, many lines that seem unnecessary. Hoping there is a more elegant solution. Thanks in advance!
source
share