0 votes
in Other by Beginner (6 points)
ACCESS DB query: i have data which contains asterisk in it. I need to pull that, i have below condition it pulls any number of asterisk in the data but i need to restrict with 3 asterisk in it. I hope you can help on this

Like "*[*]*"

2 Answers

+1 vote
by Skilled (419 points)
selected by
Best answer

For an Access DB Query, you have the correct syntax for any number of asterisks. You need a second Field:

Diff: Len([DataWithAsterisks])-Len(Replace([DataWithAsterisks],"*",""))

Its Criteria is 3 and you want to untick the box on the Show row.

Here is an example:

Access DB Query to limit number of asterisks in data

by Beginner (6 points)
Thanks for your support
by Skilled (419 points)
You're welcome, subhas. Happy to help!
0 votes
by Beginner (86 points)

Let's suppose that you have a table called People, defined by the following SQL statement:

    Gender TEXT NOT NULL,
    Remarks TEXT);

Then, the table is filled with the following sample data:

The People Table
MarkM12This guy has a cat named ***
LukeM34*** is his all-time favourite rock record.
GloriaF22She has attented *** concerts in the last year.

We'll use the following statements to query the table:

SELECT Remarks FROM People WHERE Remarks LIKE '***%';
SELECT Remarks FROM People WHERE Remarks LIKE '%***';
SELECT Remarks FROM People WHERE Remarks LIKE '%***%';

By using those queries, we'll get the following results:

  1. The LIKE '***%' clause selects just those records whose Remarks field starts with `***`, i.e. it selects just `*** is his all-time favourite rock record`.
  2. The LIKE '%***' clause selects just those records whose Remarks field ends with `***`, i.e. it will select just `This guy has a cat named ***`.
  3. The LIKE '%***%' clause selects just those records whose Remarks field contains `***`, i.e. it will select all records from the People table.

I noticed that you tried to use `*` as a pattern for a regular expression, but the LIKE clause only allows to use  `_` (matching one instance of any character) and `%` (matching zero or more of any character), as you can see from the official reference.

Welcome to wellsr Q&A
wellsr Q&A is the VBA and Python programming community that rewards you for learning how to code.

Getting Started
VBA Cheat Sheets (On Sale Now)

Earn free prizes for asking VBA and Python questions and for answering questions asked by others in our community.

Looking for something else? Hire our professional VBA Help, instead.

What makes us different?
Our points system rewards you with a chance for free gifts based on the quality of your questions and answers. All you have to do is post and you could get rewarded, like these members:

ParserMonster $25 Amazon Gift Card
Hightree $10 Amazon Gift Card
Thales1 $10 Amazon Gift Card
runfunke $10 Amazon Gift Card
coolag $10 Amazon Gift Card
Siew Hun $10 Amazon Gift Card

So, why don't you join us? It really is an encouraging way to motivate members in our VBA and Python community.


For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.