简体   繁体   中英

Use function in join

Is this possible to use function in Join. Why i want this Because my function return value from table where the data in comma separated

Example - '20122200',20122',

Return from function

20122200 
20122





 select FileNamePath,ex.ExprtINI,PROCESSED  from OrderExports OE
 INNER JOIN ExporterFiles EX ON EX.RefVal= CAST (OE.ID  as varchar)
 where    
  EX.ExportName = 'Ensenda'

in above sql statement i want to use function at EX.RefVal= CAST (OE.ID as varchar) to EX.RefVal= fngetAllRefValfromExporterFiles() . i tried to do this but can't do. So can you please help me about this.

Since it is a table valued function you cannot use it like that.

Use the TVF result in IN clause

EX.RefVal in (select fun_col from fngetAllRefValfromExporterFiles())

or you can join the function with your table

yourtable EX
 JOIN Fngetallrefvalfromexporterfiles() b
   ON EX.RefVal = b.fun_col 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM