0

I confirmed that the columns in the SQL table contain the results I'm searching for (the results being NA), but when I use the query below, no results are returned. Could I get some help with this please?

SELECT DISTINCT * 
FROM [DB_NAME].[dbo].[TABLE_NAME]
WHERE BECDescription like '%Time Warner%' AND
      (CONCAT(PhysicalAddress1, PhysicalCity, PhysicalStateProvince) like ('%NA%  %NA% %NA%')
      ) AND
      PhysicalCountry like '%NA%' AND
      CarrierName like '%NA%' AND
      CurrNetChargeAmt = 1326.00
1
  • 2
    Please include some sample data for the MSAudit table which explains what you are trying to do here. Commented Jul 16, 2019 at 15:43

2 Answers 2

1

I'm a little lost on why you are using CONCAT() here. Doesn't this do what you want?

WHERE BECDescription like '%Time Warner%' AND
      PhysicalAddress1 like '%NA%' AND
      PhysicalCity like '%NA%' AND
      PhysicalStateProvince like '%NA%' AND
      PhysicalCountry like '%NA%' AND
      CarrierName like '%NA%' AND
      CurrNetChargeAmt = 1326.00

It is certainly simpler to understand.

Sign up to request clarification or add additional context in comments.

Comments

0

You concat PhysicalAddress1, PhysicalCity, PhysicalStateProvince but you add spaces between the '%NA'.

Try

SELECT DISTINCT * 
FROM [db_name].[dbo].[table_name]
WHERE BECDescription like '%Time Warner%' AND (CONCAT(PhysicalAddress1, ' ', PhysicalCity, ' ', PhysicalStateProvince) like ('%NA% %NA% %NA%')) AND PhysicalCountry like '%NA%' AND CarrierName like '%NA%' AND CurrNetChargeAmt = 1326.00

1 Comment

Thank you for your help and the quick response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.