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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:09:30+00:00 2026-05-20T20:09:30+00:00

In MySQL I have one particular cell with data something like this 5,6,7,8,9 If

  • 0

In MySQL I have one particular cell with data something like this

5,6,7,8,9

If I need to search for specific 2 numbers one after another I do a query with LIKE statement for those 2 particular numbers. For ex. I need to check if there’s a row with numbers 6 & 7 *in a row* I do

SELECT * FROM table WHERE column LIKE '%,6,7,%' OR column LIKE '%,6,7' OR column LIKE '6,7,%'

It’s little redundant and clumsy. If I ‘convert’ those numbers into multiple rows, for ex. every number would become it’s own row with column ‘numbers‘ ordered with ‘sort‘ column so I know the order of rows.

id    numbers    sort
55     8         4
56     6         2
57     5         1
58     7         3
59     9         5
...

What’s the identical query for this case? So I would have the same result as with the query above. I need to order the query with sort column and check if the numbers 6,7 are occurring one after another with that sorting.

  • 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-20T20:09:31+00:00Added an answer on May 20, 2026 at 8:09 pm

    Should be something like this. (if I understood right your problem). It will return nothing if the 2 numbers are not in sequence by the sort column.

    select * 
    from table t1
    join table t2 on t1.sort=t2.sort+1
    where t1.numbers=6 and t2.numbers=7
    

    if you do not know which one should be first you can use it like this:

    select * 
    from table t1
    join table t2 on t1.sort=t2.sort+1 or t1.sort+1=t2.sort
    where t1.numbers=6 and t2.numbers=7
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL table that will only have one row. What should my
I have a mysql database which as one of the fields contains a html
I have two mysql tables, one containing details on cars and one containing all
I have a MySQL table with approximately 3000 rows per user. One of the
I have a bunch of tasks in a MySQL database, and one of the
I am fairly new to MySQL and have a project in which I need
I'm writng a small application in PHP + MySQL and have come to the
Anyone knows how to get sum of number? For example i have mysql column
I have a MySQL query that returns a result with a single column of
I have a MySQL database behind a firewall which can only be accessed via

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.