01-29-2015 11:39 AM - edited 03-14-2019 02:23 PM
Hello,
I am working on a SQL query that does a lookup of the calling number and the last four digits entered by the customer. If I hard code the lastFourGC variable I am able to return a successful result. If I use $lastFourGC I get the following error.
$callingNumber - Is exactly that, the calling number.
$lastFourGC - Is the last four digits collected from the customer.
SELECT * FROM GiftCardFulfillment WHERE Phone=$callingNumber and Right (GiftCard16DigitNumber, 4)=$lastFourGC
01-29-2015 04:32 PM
You need to encapsulate the string variable with quotes. Try the following:
SELECT * FROM GiftCardFulfillment WHERE Phone=$callingNumber and Right (GiftCard16DigitNumber, 4)='$lastFourGC'
01-30-2015 04:12 AM
Tanner,
I had tried that with single and double quotes and it didn't work. I did end up getting it to work by rearranging the order. I'm not sure why that worked, but this is what the query looks like now and it works.
SELECT * FROM [leads].[dbo].[GiftCardFulfillment]
WHERE Right (GiftCard16DigitNumber, 4)=$lastFourGC and Phone=$callingNumber
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide