Dulini Atapattu
Dulini Atapattu

Reputation: 2735

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

Upvotes: 0

Views: 4104

Answers (2)

Binary Worrier
Binary Worrier

Reputation: 51739

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

Upvotes: 1

Melsi
Melsi

Reputation: 1462

From my experience in the past... yes access syntax has some minor difference that make even simple things a trouble.

I don't remember how but check around a way to make access show the sql from some results you retrieved in a graphical way, there must be some show sql button somewhere.

Once there examine carefully the sql syntax, then test your sql in access' editor. So the main idea is let access show you the way!

Upvotes: 0

Related Questions