Facing issue with WHERE query

BizBoy

Board Regular
Joined
Jul 26, 2012
Messages
118
Hi,

I am trying a WHERE query for learning purpose.
I am facing an issue while writing this query.

When I copy where criteria from table, query gives result.
But when I manually type criteria, I get blank records.

Please see below queries I am using. I can not see any difference in both.
However, one query gives result and one does not.
The only change is 'London ' is copied from table in one query and in second query I have manually typed 'London '

Can anyone help me in this please.

SELECT * from Customers where City = 'London '
SELECT * from Customers where City = 'London '

Table copied from below link.

https://www.w3schools.com/sql/sql_distinct.asp
 
Last edited:

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I notice that you have a space after the word "London ".
If you are copying it from the internet, you may have a special space (like a non-breaking space), which is different from a regular space (data copied from the internet often uses these special spaces instead).

Personally, I do not like using spaces at the end of criteria values. I would probably do this instead:
Code:
SELECT * from Customers where LEFT(City,6)='London';
Then, it doesn't matter at all what comes after the word "London".
 
Upvote 0
THis might have to do with the encoding of the the text values. Data copied from web pages can often have weird problems like this.
 
Upvote 0
Hi Joe sir,
Thanks a lot for the help.

I try TRIM function in Excel VBA in such cases but was not aware that I can use LEFT in access to resolve this issue.
Have a nice day ahead. :)
 
Upvote 0
Hi Xenou sir, thanks a lot for the help. Since I have copied this data for learning purpose.
I will trim this in excel before creating an access table for the same details.
This might be more safe. Have a nice day ahead. :)
 
Upvote 0
Did bit data cleaning along with TRIM and CLEAN in excel to remove extra spaces.
Now it is working fine. Thanks.
 
Upvote 0

Forum statistics

Threads
1,214,563
Messages
6,120,248
Members
448,952
Latest member
kjurney

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top