Search code examples
databasems-accesssql-like

Simple like-query does not work in MS-Access


I have a simple Ms-Access database with one table named Student and it has two columns ID and Name.

When I the database in Access and enter the query

select * from Student where Name like 'J%'

in its SQL view, it gives an empty resultset.

But the table has a Name called John.

I tried with other databases and tables also with like-queries, but none works.

Can anyone please tell if there is any special reason for this???

Thank you

Edit:

The same query works with c sharp code


Solution

  • What you need is

    select * from Student where Name like 'J*'
    

    or possibly (because I don't have access handy to check, possibly either will work)

    select * from Student where Name like "J*"
    

    The * is the wild card character for MsAccess