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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:05:18+00:00 2026-06-10T13:05:18+00:00

My current query looks like this: $query = SELECT * FROM t WHERE (data

  • 0

My current query looks like this:

$query = "SELECT * FROM t WHERE (data LIKE '$findme') OR (data LIKE '%$findme|%') OR (data LIKE '%|$findme%')";

The data in this column contains items that are delimited by pipe symbols (“|”) and I need the query to find all records that contain any occurrences of an item in this field. Additionally, if there’s only one item in this column, there will not be a “|” symbol present.

EXAMPLE:

$findme = "12";

QUERY SHOULD MATCH:

13|23|12
12
12|23
3|12|42

QUERY SHOULD NOT MATCH:

123|32
34|123

I’m not sure if using REGEXP would make this easier, but if so, any solution is welcome. Thanks!

SQLFiddle Example:
http://sqlfiddle.com/#!3/32afd/5

  • 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-10T13:05:19+00:00Added an answer on June 10, 2026 at 1:05 pm

    Using a combination of REPLACE() and FIND_IN_SET(), you can replace the | with commas, and locate your value $findme in the pipe-delimited set:

    SELECT * 
    FROM table
    /* Replace | with , and search in the set */
    WHERE FIND_IN_SET('$find_me', REPLACE(data, '|', ',')) > 0
    

    Note that this only works if the delimited values in data do not contain commas.

    In the long run, the appropriate solution to this is to separate out the delimited column data into another properly normalized one to many table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that looks like this: SELECT OrganizationName, OrganizationID, ReceivableStatus, InvoiceFee FROM
My current query looks something like this: SELECT SUBSTR(name,1,1), COUNT(*) FROM files GROUP BY
My current query looks like this: SELECT DISTINCT (member), count( UID ) AS numUID
My current query reads: SELECT entry_id, user_id, cat_id, AVG( rating ) as avg_rate FROM
If I have a query like this: String Category = HttpContext.Current.Request.QueryString[Product].ToString(); IQueryable<ItemFile> pressReleases =
I have a query that selects data from 4 tables via joins, i want
I have a table that looks a bit like this: user_id item_id bid_amount 5
I have a working query that will return some results(records) from my database, like:
I have a report that is driven by a sql query that looks like
I have a LINQ query mapped with the Entity Framework that looks something like

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.