Home > Back-end >  How to show from which table is data in results
How to show from which table is data in results

Time:11-24

I am try to find a solution how to show from which table is data.

I have two tables #_tmpImport and #_tmp_DDVI No I want to see from which table did data come from.

Example for ID:8880 I have result P ID:8881 I have result O

I want to see it like this

Example for ID:8880 I have result P - Import_TEST ID:8881 I have result O - DDV

SELECT * FROM
 case 
     when Import_TEST.XX = 'P' then 'P'
     when DDV.XX = 'O' then 'O'
     else ' '
end as Test
FROM #_tmpImport Import_TEST
full join #_tmp_DDVI DDV ON  Import_TEST.ID=DDV.ID

CodePudding user response:

Your query has an extra FROM that should be replaced with a comma.


SELECT *,
 case 
     when Import_TEST.XX = 'P' then 'P'
     when DDV.XX = 'O' then 'O'
     else ' '
end as Test
FROM #_tmpImport Import_TEST
full join #_tmp_DDVI DDV ON  Import_TEST.ID=DDV.ID

CodePudding user response:

From the information what I've gathered this is what you're trying to do:

SELECT *,
 case 
     when Import_TEST.XX IS NOT null then 'P'
     when DDV.XX IS NOT null then 'O'
     else null
end as Test
FROM #_tmpImport Import_TEST
full join #_tmp_DDVI DDV ON  Import_TEST.ID=DDV.ID

I have no way to test this at the moment, so there can be possible typos.

  • Related