1

I made table copied from W3schools 2015 ... Here's some of the data:

enter image description here

here the columns and data types i used as follows.

CustomerID = int
CustomerName = varchar
ContactName = varchar
Address = varchar
City = varchar
PostalCode = varchar
Country = text

When i used the following query i got the actual result.

SELECT * FROM Customers WHERE Country LIKE 'U%';    SELECT * FROM Customers WHERE Country LIKE 'M%';    SELECT * FROM Customers WHERE Country LIKE 'G%';

Now the problem was that When i used the following query, i weren't getting actual result.

SELECT * FROM Customers WHERE Country LIKE 's%';    

i didn't see any row !! But We should have seen the following output,

enter image description here

why ?? can anybody explain pls...

Moreover I am totally in Novice phase..

Thanks in Advance

2 Answers2

0

May be, This is Because of Your Country Column Starting with 'S'(which we think) are not really Starting with 'S', May be it's first charter is a Space.(Just A Guess)

so, For this Case you can try Once,

SELECT * FROM Customers WHERE rtrim(ltrim(Country)) LIKE 's%';  

or

SELECT * FROM Customers WHERE replace(Country,' ','') LIKE 's%'; 
A_Sk
  • 4,532
  • 3
  • 27
  • 51
-1

See How can I search (case-insensitive) in a column using LIKE wildcard?

Community
  • 1
  • 1
Mark He
  • 735
  • 7
  • 14