possible to get results of 3 different tables in 1 set of column results?
-
I painted myself into a corner here. Was going to do a join, but realized I had nothing to join. Is it possible to get this result in 1 set?
SELECT
cc.ID
, cc.CustomerID
, cc.SessionID
, cc.LoginID
, cc.CardLabel
, cc.CardBrand
, cc.CardName
, cc.CardNumber
, cc.ExpMonth
, cc.ExpYear
, cc.CVV2
, ba.Name1
, ba.Name2
, ba.CompanyName
, ba.StreetAddress1
, ba.StreetAddress2
, ba.City
, ba.StateCode
, ba.PostalCode
, ba.CountryCode
, ba.Phone
, sa.Name1
, sa.Name2
, sa.CompanyName
, sa.StreetAddress1
, sa.StreetAddress2
, sa.City
, sa.StateCode
, sa.PostalCode
, sa.CountryCode
, sa.Phone
FROM CUSTOMER_CARDDATA cc
WHERE cc.ID = @CC_IDFROM CUSTOMER_BILLING_ADDRESS ba
WHERE ba.ID = @BA_IDFROM CUSTOMER_SHIPPING_ADDRESS sa
WHERE sa.ID = @SA_ID -
I painted myself into a corner here. Was going to do a join, but realized I had nothing to join. Is it possible to get this result in 1 set?
SELECT
cc.ID
, cc.CustomerID
, cc.SessionID
, cc.LoginID
, cc.CardLabel
, cc.CardBrand
, cc.CardName
, cc.CardNumber
, cc.ExpMonth
, cc.ExpYear
, cc.CVV2
, ba.Name1
, ba.Name2
, ba.CompanyName
, ba.StreetAddress1
, ba.StreetAddress2
, ba.City
, ba.StateCode
, ba.PostalCode
, ba.CountryCode
, ba.Phone
, sa.Name1
, sa.Name2
, sa.CompanyName
, sa.StreetAddress1
, sa.StreetAddress2
, sa.City
, sa.StateCode
, sa.PostalCode
, sa.CountryCode
, sa.Phone
FROM CUSTOMER_CARDDATA cc
WHERE cc.ID = @CC_IDFROM CUSTOMER_BILLING_ADDRESS ba
WHERE ba.ID = @BA_IDFROM CUSTOMER_SHIPPING_ADDRESS sa
WHERE sa.ID = @SA_IDIf there is no relationship between the tables then that would not be possible unless you create one or you are getting only 1 record from each table, then you could use a cross join
Never underestimate the power of human stupidity RAH
-
I painted myself into a corner here. Was going to do a join, but realized I had nothing to join. Is it possible to get this result in 1 set?
SELECT
cc.ID
, cc.CustomerID
, cc.SessionID
, cc.LoginID
, cc.CardLabel
, cc.CardBrand
, cc.CardName
, cc.CardNumber
, cc.ExpMonth
, cc.ExpYear
, cc.CVV2
, ba.Name1
, ba.Name2
, ba.CompanyName
, ba.StreetAddress1
, ba.StreetAddress2
, ba.City
, ba.StateCode
, ba.PostalCode
, ba.CountryCode
, ba.Phone
, sa.Name1
, sa.Name2
, sa.CompanyName
, sa.StreetAddress1
, sa.StreetAddress2
, sa.City
, sa.StateCode
, sa.PostalCode
, sa.CountryCode
, sa.Phone
FROM CUSTOMER_CARDDATA cc
WHERE cc.ID = @CC_IDFROM CUSTOMER_BILLING_ADDRESS ba
WHERE ba.ID = @BA_IDFROM CUSTOMER_SHIPPING_ADDRESS sa
WHERE sa.ID = @SA_ID -
If there is no relationship between the tables then that would not be possible unless you create one or you are getting only 1 record from each table, then you could use a cross join
Never underestimate the power of human stupidity RAH
-
I painted myself into a corner here. Was going to do a join, but realized I had nothing to join. Is it possible to get this result in 1 set?
SELECT
cc.ID
, cc.CustomerID
, cc.SessionID
, cc.LoginID
, cc.CardLabel
, cc.CardBrand
, cc.CardName
, cc.CardNumber
, cc.ExpMonth
, cc.ExpYear
, cc.CVV2
, ba.Name1
, ba.Name2
, ba.CompanyName
, ba.StreetAddress1
, ba.StreetAddress2
, ba.City
, ba.StateCode
, ba.PostalCode
, ba.CountryCode
, ba.Phone
, sa.Name1
, sa.Name2
, sa.CompanyName
, sa.StreetAddress1
, sa.StreetAddress2
, sa.City
, sa.StateCode
, sa.PostalCode
, sa.CountryCode
, sa.Phone
FROM CUSTOMER_CARDDATA cc
WHERE cc.ID = @CC_IDFROM CUSTOMER_BILLING_ADDRESS ba
WHERE ba.ID = @BA_IDFROM CUSTOMER_SHIPPING_ADDRESS sa
WHERE sa.ID = @SA_IDIf there's exactly one matching record to each other and they're in the same order you could use the ROWID to join them / to update the tables without ID with the ID from CUSTOMER_CARDDATA.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson