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 7034039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:08:16+00:00 2026-05-28T01:08:16+00:00

I did a bit of research about sql escape characters and count statements and

  • 0

I did a bit of research about sql escape characters and count statements and didnt find a solution to my question. Even though I used stuff like:

SELECT * FROM table WHERE path LIKE '%/_%' ESCAPE '/';

I got a table where in a column there is paths so I want to select the items where I have certain number of slashes:

ID    DIRECTORY
1     root/A
2     root/B
3     root/A/1/2
4     root/B/1/2
5     root/A/1
6     root/B/2

so, how do I select for example the elements that have only 2 slashes??

Edit 1: This is to be done in Android SQL-Lite Database

  • 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-05-28T01:08:17+00:00Added an answer on May 28, 2026 at 1:08 am

    You can use this trick to count occurrences of a character in a string:

    SELECT LENGTH('path') - LENGTH(REPLACE('path', '/', '')) AS `occurrences`
    

    So you can achieve the goal with

    SELECT id, path FROM
      (SELECT id, path, LENGTH('path') - LENGTH(REPLACE('path', '/', '')) AS `occurrences`
       FROM table) temp
    WHERE occurrences = 2
    

    However, I expect performance will be terrible. If you are going to query like that, consider adding a column with the path depth so that you can query directly with

    SELECT id, path FROM table WHERE depth = 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lately I did a bit of research about the Digital Signature Algorithm and how
I'm a bit freaked about what I just read. I did some research, as
I want to make a bitset in C++. I did a bit of research.
I did a lot of research on this subject but couldn't find any end
I have windows 7 (64-bit) and just upgraded IE9 in my machine. I did
I know this topic is bit old, but i did surf the web and
Did about 30 minutes worth of searching, found lots of relevant info, but none
I have done quite a bit of research on this issue and have not
I did a bit of searching and found this thread on the topic but
Okay, so I did all the research for this issue but none of the

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.