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 need to have MySQL query like this one: UPDATE table_name SET 1 =
I'm after a model-based database class for PHP/MySQL. But it must have one particular
I have a mysql table that have several records linked to one particular tag.
I have one main array which is the returned data from a MySQL query
I have a mysql stored procedure from this ( google book ), and one
I have a mysql table and one of the fields is 'template'. This field
I have one table like this account_id (INT) inviter_id (INT) Now, logged in user
by default I have one column in MySQL table to be NULL. I want
I'm quite new to MySQL and I'm confused with one problem: I have one
Ok, so i have one really monstrous MySQL table (900k records, 180 MB total),

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.