Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Need to Include a message from a table in the query below


The table name is MESSAGE_RESPONSE

fields
------
i. message_initial
ii. message_response


Original Query
---------------

SELECT A.COMPLAINANT, A.SERVICE_PROVIDER,
A.COMP_DATE , A.ACTUAL_DAYS
FROM MASTER_ALERT A
LEFT JOIN RESPONSE R ON A.PTICK_CODE =R.PTICK_CODE
WHERE R.RESOLUTION_STAT_FRONT IN ('UNSATISFACTORY' ,'UNHAPPY','BAD')
AND DATEADD(DD,A.DAYS_INCEPTION,A.COMP_DATE)<=GETDATE() AND A.ACTUAL_DAYS >1


tried this


SELECT A.COMPLAINANT, A.SERVICE_PROVIDER,
A.COMP_DATE , A.ACTUAL_DAYS ,
C.MESSAGE_RESPONSE AS MESSAGE
FROM MASTER_ALERT A
LEFT JOIN RESPONSE R ON A.PTICK_CODE =R.PTICK_CODE
WHERE R.RESOLUTION_STAT_FRONT IN ('UNSATISFACTORY' ,'UNHAPPY','BAD')
AND DATEADD(DD,A.DAYS_INCEPTION,A.COMP_DATE)<=GETDATE() AND A.ACTUAL_DAYS >1

Where do you put the table 'MESSAGE_RESPONSE C' in the query

-- C.MESSAGE_RESPONSE AS MESSAGE

What I have tried:

This is an ongoing development
Posted
Updated 27-Mar-18 1:32am

1 solution

You would have to add another JOIN:
FROM MASTER_ALERT A 
LEFT JOIN RESPONSE R ON A.PTICK_CODE =R.PTICK_CODE
JOIN MESSAGE_RESPONSE c ON c.? = ?.?
But we can't tell you what to replace the question marks with - we have no idea how your table data is related, and in order to use a JOIN you need to have a relationship (though not necessarily a formal one) between the tables. Almost certainly, MESSAGE_RESPONSE.message_initial contains values that are stored in one of your other tables, but we have no idea which one, or which column.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900