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 (265 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 (265 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.

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

What makes us different?
Our points system rewards you with a chance for free gifts based on the quality of your questions and/or answers. Users that ask great questions, may be given complimentary gift cards or training material.

Getting Started

So, why don't you join us? It really is a neat way to reward the most dedicated members in our VBA and Python community.

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