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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:17:42+00:00 2026-06-14T22:17:42+00:00

Assume my table column contains the following 2 string rows: 1, 5, 2, 31,

  • 0

Assume my table column contains the following 2 string rows:

       1, 5, 2, 31, 12, 1212, 111
       21, 25, 32, 43, 112, 212, 311

I need a query to select a row that contains number 1 and contains number 2

My Query is:

      SELECT *
      FROM MyTable
      WHERE My_String LIKE '%1%' AND My_String LIKE '%2%'

now this returns both of the rows when i want it to return only the first row.

It selects second row because numbers 21, 25, 32, 112, 212, 311 also contain number 1 and 2.

My question is how do i select all those rows where numbers 1 and 2 are contained in a string but not in 2-3 digit numbers. I want it to match strictly to those 1 and 2

  • 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-14T22:17:43+00:00Added an answer on June 14, 2026 at 10:17 pm

    http://www.sqlfiddle.com/#!2/b082d/5

    select * from testtable
    where instr(concat(', ', longstring, ', '), ', 2,') >0;
    
    select * from testtable
    where instr(concat(', ', longstring, ', '), ', 1,') >0 
    and  instr(concat(', ', longstring, ', '), ', 2,') >0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to select rows randomly from an Oracle DB. Ex: Assume a table
I have following query select * from table1 if table1 contains text type column/columns
I need to store a large table (several millions or rows) that contains a
Assume a query of the following form operatingExpenses = Expense.find(:all, {:select=>categories.activityType, categories.name heading, sum(amount)
Assume I have a table like this: column A(int) column B(int) 1 2 2
Assume I have the following style table, col1 col2 and col3 have same value
Lets assume I get an HTML table as a string, and I want -
Consider the following table: People FirstName nvarchar(50) LastName nvarchar(50) Let's assume for the moment
I really need help getting this query right. I can't share actual table and
I need to synchronize two tables. Let's assume that the tables contain following columns:

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.