Tuesday, March 20, 2012

Pulling data from two tables

Here is my current query
Use Winpayment
GO
SELECT
convert(char(11), retrieval_reference_number) RR,
message_type,
authorization_identification,
convert(char(8), card_acceptor_identification) SN,
convert(char(25), transaction_name) TransactionName,
isnull(convert(char(2), id_code_1), ' ') ID,
convert (char (20), id_number_1)CardNumber,
convert(char(20), time_stamp) Time,
convert(char(2), response_code) RC,
isnull(convert(char(2), host_response_code), '') HRC,
convert(char(20), host_response_string)Message,
convert(char(7), stan) STAN,
convert(char(12), transaction_amount) Amount,
settlement_data
FROM
financial_message (NOLOCK)
WHERE
settlement_batch_number = '787'
and
LEN (card_acceptor_identification) < 6
and
(id_code_1 = 'PL' or id_code_1 = 'WF' or id_code_1 = '00' or
id_code_1 = 'YF')
and
message_type != 0100
ORDER BY time_stamp
All of this data is being pulled from the financial_message table. I want
to add another and statement that says
wp_category_code = '002' which comes from a table called financial_category
Do they need to have a common column in both tables?
Both financial _message and financial category have a column called
retrieval_reference_number
I am looking for a query that will search all those things from financial
message and then pull only data that also have a wp_category_code = '002'
from financial_category. Is there anyway to pull this data from two tables?
Any help would be greatly appreciated. Thanks......
FROM
financial_message FM (NOLOCK)
INNER JOIN financial_category FC
ON FM.retrieval_reference_number = FC.retrieval_reference_number
AND FC.wp_category_code = '002'
WHERE
....
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com
"tarheels4025" <tarheels4025@.discussions.microsoft.com> wrote in message
news:F2EA0A50-DED7-4D79-A068-AE734D090F6B@.microsoft.com...
> Here is my current query
> Use Winpayment
> GO
> SELECT
> convert(char(11), retrieval_reference_number) RR,
> message_type,
> authorization_identification,
> convert(char(8), card_acceptor_identification) SN,
> convert(char(25), transaction_name) TransactionName,
> isnull(convert(char(2), id_code_1), ' ') ID,
> convert (char (20), id_number_1)CardNumber,
> convert(char(20), time_stamp) Time,
> convert(char(2), response_code) RC,
> isnull(convert(char(2), host_response_code), '') HRC,
> convert(char(20), host_response_string)Message,
> convert(char(7), stan) STAN,
> convert(char(12), transaction_amount) Amount,
> settlement_data
>
> FROM
> financial_message (NOLOCK)
> WHERE
> settlement_batch_number = '787'
> and
> LEN (card_acceptor_identification) < 6
> and
> (id_code_1 = 'PL' or id_code_1 = 'WF' or id_code_1 = '00' or
> id_code_1 = 'YF')
> and
> message_type != 0100
>
> ORDER BY time_stamp
> All of this data is being pulled from the financial_message table. I want
> to add another and statement that says
> wp_category_code = '002' which comes from a table called
> financial_category
> Do they need to have a common column in both tables?
> Both financial _message and financial category have a column called
> retrieval_reference_number
> I am looking for a query that will search all those things from financial
> message and then pull only data that also have a wp_category_code = '002'
> from financial_category. Is there anyway to pull this data from two
> tables?
> Any help would be greatly appreciated. Thanks.|||I have an example from the one steetlement_batch_number and it isn't pulling
it with this query. Do you know why this might be? Thanks.
"Roji. P. Thomas" wrote:

> .....
> FROM
> financial_message FM (NOLOCK)
> INNER JOIN financial_category FC
> ON FM.retrieval_reference_number = FC.retrieval_reference_number
> AND FC.wp_category_code = '002'
> WHERE
> .....
>
> --
> Roji. P. Thomas
> Net Asset Management
> https://www.netassetmanagement.com
>
> "tarheels4025" <tarheels4025@.discussions.microsoft.com> wrote in message
> news:F2EA0A50-DED7-4D79-A068-AE734D090F6B@.microsoft.com...
>
>

No comments:

Post a Comment