0 votes
ago in Other by Beginner (106 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
ago by Beginner (204 points)
selected ago 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

ago by Beginner (106 points)
Thanks for your support
ago by Beginner (204 points)
You're welcome, subhas. Happy to help!
0 votes
ago by Beginner (186 points)

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

CREATE TABLE People(
    Name TEXT PRIMARY KEY,
    Gender TEXT NOT NULL,
    Age INTEGER NOT NULL,
    Remarks TEXT);

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

The People Table
NameGenderAgeRemarks
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 as your contributions grow. The more points you earn, the better the prizes.

Getting Started
Register
Prizes

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

Top Users Mar 2019
  1. YasserKhalil

    306 Points

  2. ParserMonster

    204 Points

  3. Alberto Semat

    186 Points

  4. danmcg

    127 Points

  5. Abdan

    124 Points


Prizes for March 2019
Terms and Conditions
1st place (1) 1-year MyExcelOnline Academy Membership
(2) My First Add-in Dev Pack & Course
(3) AutoMacro: VBA Code Generator (Developer)
(4) VBA Cheat Sheet Bundle
(5) $35 Amazon Gift Card
2nd place (1) My First Add-in Dev Pack & Course
(2) 101 Most Popular Excel Formulas E-Book
(3) VBA Cheat Sheet Bundle
(4) $25 Amazon Gift Card
3rd place (1) Mouse to Macro
(2) VBA Cheat Sheet Bundle
(3) $15 Amazon Gift Card
...