Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8030885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:54:46+00:00 2026-06-05T00:54:46+00:00

I am trying to return results that replace record Ids with their more human

  • 0

I am trying to return results that replace record Ids with their more human readable description values. Changing the column names via AS is simple enough but I think a subquery is going to be needed to take an ID values such as PT1 and get the Description value as a replacement.

For instance I have a table1 with some columns like:

id| Paper | Coating | CreatedOn | Type

1 | pid3 | cid5 | some date | tid2
2 | pid2 | cid8 | some date | tid3
3 | pid1 | cid1 | some date | tid4

Then table2 has details on the reference id in the parent table:

id| fKey | description |

1 | pid3 | some user friendly description |
1 | pid1 | some other description |
1 | pid2 | something else |

Similar for tables three and four

I tried to use a JOIN linking the Paper IDs but this returned no values

SELECT table1.Paper as ‘Paper Name’, table1.Coating, table1.CreatedOn, table1.Type, table2.description
FROM table1
JOIN table2 ON table1.Paper = table2.fKey

My actual query is as shown but the table names were altered:

SELECT PD_ComboRun.RNId AS 'RUN #', PD_ComboRun.RNQty AS Quantity,
       PD_ComboRun.PTId, PD_ComboRun.PSId AS Size, PD_ComboRun.RNType AS 'Run Type',
       PD_ComboRun.PCId AS 'Press Coating', PD_ComboRun.UVFid AS 'UV Finish',
       PD_ComboRun.Notes AS 'Special Instructions', PD_ComboRun.CreatedOn AS 'Date Created', 
       SM_PaperType.PTCode AS Paper, SM_PaperType.PTId AS Expr1
FROM  PD_ComboRun 
LEFT JOIN SM_PaperType ON SM_PaperType.PTId = PD_ComboRun.PTId

Can someone please point me the right direction to achieve this goal? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:54:48+00:00Added an answer on June 5, 2026 at 12:54 am

    This works perfectly as I presume you need. I modified it to use your tables and fields.

    DECLARE @PD_ComboRun TABLE(RNId int,RNQty int,PTId varchar(10),
        PSId varchar(10),PCId varchar(10),UVFid varchar(10),createdOn smalldatetime, 
        RNType varchar(10),Notes varchar(MAX))
    INSERT INTO @PD_ComboRun
    SELECT 1,5,'pid3','psid1','cid5','uvid1',GETDATE(),'tid2',''
    UNION ALL
    SELECT 2,10,'pid2','psid2','cid8','uvid4',GETDATE(),'tid3','notes'
    UNION ALL
    SELECT 3,7,'pid1','psid1','cid1','uvid1',GETDATE(),'tid4',''
    
    SELECT * FROM @PD_ComboRun
    
    DECLARE @SM_PaperType TABLE(PTId varchar(10),PTCode varchar(50))
    INSERT INTO @SM_PaperType
    SELECT 'pid3','some user friendly description'
    UNION ALL
    SELECT 'pid2','some other description'
    UNION ALL
    SELECT 'pid1','something else'
    
    SELECT * FROM @SM_PaperType
    
    SELECT t1.RNId AS [Run #], t1.RNQty AS Quantity,
        t1.PTId,t1.PSId AS Size,t1.RNType AS [Run Type], 
        t1.PCId AS [Press Coating], t1.UVFid AS 'UV Finish', 
        t1.Notes AS 'Special Instructions',t1.createdOn AS 'Date Created',
        t2.PTCode AS Paper,t2.PTId AS Expr1
    FROM @PD_ComboRun t1 INNER JOIN @SM_PaperType t2 ON t1.PTId=t2.PTId
    

    RESULTS

    @table1

    1   5   pid3    psid1   cid5    uvid1   2012-05-31 17:45:00 tid2    
    2   10  pid2    psid2   cid8    uvid4   2012-05-31 17:45:00 tid3    notes
    3   7   pid1    psid1   cid1    uvid1   2012-05-31 17:45:00 tid4    
    

    @table2

    pid3    some user friendly description
    pid2    some other description
    pid1    something else
    

    @combined
    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I'm trying to return a message when there are no results for the
I am trying to return a number based on the count of results from
I'm trying to use $.post within a function, get the results, then return the
Im trying to return the value that a $ajax call returns, from a function
Im trying to return a SimpleQuery list that queries a single table and uses
I'm trying to convert a pretty simple script that takes search results from Twitter
When trying to return a simple set of results from my database table 'checklist'
I'm trying to return the result of a entity framework query into my own
I'm trying to return a result and a nested result in a linq to
I am having trouble trying to represent the below SQL (which returns the results

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.