Using query result field as database name in same query

前端 未结 2 1684
别那么骄傲
别那么骄傲 2021-01-29 00:53

Probably a long shot with this...

I have two databases \"Job Register\" and \"Job001\".

I want to retrieve a list of the jobs that have had a meeting, and the la

相关标签:
2条回答
  • 2021-01-29 01:17

    Your question is unclear a bit, but I think you are looking for

    SELECT JR.JobNumber,
           JR.IsComplete,
           J.DateModified
    FROM JobRegister JR INNER JOIN Job001 J
    ON JR.JobNumber = J.JobNumber
    WHERE DocumentRevision = 'B'; 
    

    Also JobNumber in both tables should be the same datatype.

    Demo

    0 讨论(0)
  • 2021-01-29 01:22
    SELECT JR.JobNumber,
           JR.IsComplete,
           J.DateModified
    FROM JobRegister JR INNER JOIN CONCAT('Job', JR.JobNumber) J
    ON JR.JobNumber = J.JobNumber
    WHERE DocumentRevision = 'B';
    
    0 讨论(0)
提交回复
热议问题