Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9217811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:43:00+00:00 2026-06-18T02:43:00+00:00

I have a table in Mysql where I have some D and C classes

  • 0

I have a table in Mysql where I have some D and C classes of IPs and I use this table to test if a request IP is in the database OR belongs to the C class like that:

select * from My_Table 
where '192.168.1.12' LIKE CONCAT(ip, '%');

(where 192.168.1.12 is the request IP I am testing against my table)

In my Database, if I have the ip ‘192.168.1’ in C format, I will get a match.

I was thinking about using MongoDB and have the same information in documents where each IP (either in C or D class format) is the _id (which is indexed by default).

How can I get it to work with MongoDB if regex would work just the opposite way? (if I had the C class beforehand)

If I split every request IP into a C class to check with regex like:

db.my_table.find(_id: '^/split_ip/')

I would have to check in my application again every result by iteration and I think that wouldn’t be a good solution.

So, I am wondering if you have any advice or suggestion to give me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:43:01+00:00Added an answer on June 18, 2026 at 2:43 am

    You could use the $in operator to get all matching from a single query.

    { _id: {$in : [/^192.0.1.1/, /^194.1.1/ ] }}

    Becuase you’re using /^ option in regex, the index will be used.

    Does that help?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in MySQL That looks like the following: date |storenum |views
I have a table in mysql like this Name Result T1_09_03_2010 fail T2_09_03_2010 pass
I have mysql table like this: id, [.....], priority The priority field is used
I have a few classes that perform some MySQL queries and prepared statements. However,
I have some data in this mysql table, but it is not showing anything
I have a table which already contains an index in MySQL. I added some
Greetings, I have some mysql tables that are currently using an md5 hash as
I'm using MySQL 4.1. Some tables have duplicates entries that go against the constraints.
I have mysql table that has a column that stores xml as a string.
I have a table in MySQL that is titled accounts, inside of accounts I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.