if statement - SQL checking if value exists through multiple different tables -


lets have unique 23-digit identifier of file. check whether identifier present in of columns of rows in given tables. these tables different columns.

is there select me achieve this?

example scenario can this:

fileid = 534bde4c322755995941083

tablea (columna, columnb, columnc)

tableb (columnd)

tablec (columne, columnf)

i return record contain unique identifier , nothing more it. number of tables various columns.

is there sql statement me this?

i can iterate through records, columns, , tables seems huge overkill such task.

you can use unpivot ...

select vals tablea  unpivot( vals n in (columna, columnb, columnc)          ) vals  = '534bde4c322755995941083'  union   select columnd  tableb  columnd =  '534bde4c322755995941083'  union   select vals tablec  c  unpivot( vals n in (columne, columnf)          ) vals  =  '534bde4c322755995941083' 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -