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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:14:13+00:00 2026-06-06T04:14:13+00:00

I like to reverse this query: SELECT * FROM table WHERE status IN (

  • 0

I like to reverse this query:

SELECT * FROM table WHERE status IN ( option,option1,option2 );

in a query like

SELECT * FROM table WHERE status contains ( 'option' );

Where field ‘status’ column contains (by example): ‘option,option1’.

When I use

SELECT * FROM table WHERE status LIKE '%option%' );

It also selects the rows with a ‘status’ column that only contains ‘option1’

Is this possible?

example data:

id,name,status
1,'test1','option,option1'
2,'test2','option,option2'
3,'test3','option2'
4,'test4','option2,option3'
5,'test5','option'

SELECT * FROM table WHERE status contains ( 'option' );

This query should select select record 1,2 and 5.

‘status’ field type is varchar.

The problem is that the status fields contains data that is almost alike, exept from the added number to option. Off course this is a made up example but the real thing has this kind of parameters.

Update:
Finally found it after Gumbo’s suggestion.

I first tried Gumbo’s lead (added the > 0):

SELECT * FROM table 
    WHERE FIND_IN_SET('option', status) > 0;

But it did not work either.

After some fiddeling around I found out that the culprit were the spaces between the options in the status field. These records are imported from another source and came with spaces after the comma:

‘option, option1’ instead of ‘option,option1’

So I ended up with:

SELECT * FROM table 
    WHERE FIND_IN_SET('option', TRIM(REPLACE(status,' ',''))) > 0;

This worked for me.

  • 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-06T04:14:14+00:00Added an answer on June 6, 2026 at 4:14 am

    For comma separated values, you can use the FIND_IN_SET function to search for a value in it:

    SELECT * FROM table WHERE FIND_IN_SET('option', status);
    

    To negate the expression, use NOT or !:

    SELECT * FROM table WHERE NOT FIND_IN_SET('option', status);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked the question here and now i would like to reverse this procedure
All what Hibernate reverse engineering generates is something like this @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name
I have a query that returns all stream posts from users (with comments): SELECT
This is more a conceptual question. It's inspired from using some extremely large table
Let's say I have this table. Let's say it looks something like this: table
I have a code like this: @dns = #{params[:domain].split('/').reverse.join('.')}.#{params[:zone]} w = Whois::Client.new @r =
How would I reverse contains in a Linq-to-SQL query so that I can check
Why do we use reverse domain name like com.something. or org.something. structure for java
Is there a way to reverse the SQL Like operator so it searches a
I am looking for the C program for reverse the digits like below: If

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.