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

  • Home
  • SEARCH
  • 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 544107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:37:11+00:00 2026-05-13T10:37:11+00:00

Sorry, I should have explained better: I have a $string and I want ‘table’

  • 0

Sorry, I should have explained better: I have a $string and I want ‘table’ to be ordered by the number of times each value under ‘word’ column appears in that $string.
for that i need a query like:

'SELECT * FROM table WHERE $string 
LIKE CONCAT("%",LOWER(word),"%")...

to find the words, then I would like to order them by appearance so that:

$string = "lollipop lollipop oh la le la le lollipop";
'SELECT * FROM table'
++++++++++table++++++++++
id - word
1  - la
2  - le
3  - lollipop
4  - shooby
+++++++++++++++++++++++++

(some query to table) would output:

++++++++++table++++++++++
id - word
1  - lollipop (appears 3 times)
2  - le (appears 2 times)
3  - la (appears 2 times)
4  - shooby (appears 0 times)
+++++++++++++++++++++++++

what’s the query to do this? (btw it would be nice if the number of times each word appears in the string would show in the select table too).

  • 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-13T10:37:11+00:00Added an answer on May 13, 2026 at 10:37 am

    One trick you can use is to replace the word in the original string. Then compare how many characters were lost. Divided by the length of the word, this gives you the total number of occurrences for that word. For example:

    SELECT 
        w.word
    ,   (length(title) - length(replace(title, w.word, ''))) / length(word)
    FROM (select 'lollipop lollipop oh la le la le lollipop' as title) t
    CROSS JOIN (
        select 'la' as word
        union all select 'le'
        union all select 'lollipop'
        union all select 'shooby'
    ) w
    
    -->
    
    la          2.0000
    le          2.0000
    lollipop    3.0000
    shooby      0.0000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 318k
  • Answers 318k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Build Your App using Active Configuration = Release, then right… May 13, 2026 at 11:59 pm
  • Editorial Team
    Editorial Team added an answer Do threads have a distinct heap? This thread has some… May 13, 2026 at 11:59 pm
  • Editorial Team
    Editorial Team added an answer There's the Logica SMPP project, written in Java, that could… May 13, 2026 at 11:59 pm

Related Questions

Title says it mostly. I want to add a simple extension method to the
I have three tables in the many-to-many format. I.e, table A, B, and AB
We want to have two .NET apps running on the same machine communicate with
Sorry for the long winded title, but the requirement/problem is rather specific. With reference
Suppose I am watching something in VS2008 and I want to search the object

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.