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
Post a Comment