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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:12:10+00:00 2026-05-23T17:12:10+00:00

i have database table with few text fields which i use to filter data

  • 0

i have database table with few text fields which i use to filter data , each of this text fields contain number data separated with colon ( for example ‘1:2:4:5:6:7:9’ )

id   |  title         |  field1                 | filed2     | field3            |
1    | Some title1    |1:2:3:4:5:6:7            |1:2:3:6:7   | 1:2:4:5:7:9:10:11 | 
2    | Some title2    |1:2:3:4:5:6:7:8:9:10:11  |1:2:3:4:5:6 | 1:2:4:5:7:9:10:11 |
3    | Some title3    |1:2:3:4:5:6:7            |1:2:3:6:9   | 1:2:4:5:7:9:10:11 |
4    | Some title4    |3:4:5:6:7:10:11          |1:2:3:10:11 | 1:2:4:5:7:9:10:11 |
5    | Some title5    |1:2:3:4:5:6:7            |1:2:3:6:7   | 1:2:4:5:7:8:9:11  |
6    | Some title6    |2:3:4:5:6:7:9            |1:2:3:6:7   | 1:2:4:5:7:9       |

using a search form i use check boxes for each parameters for field1, field2 and field3 and use php foreach to create LIKE ‘%parameter%’ for each field

my SQL query look like
SELECT * FROM table WHERE (field1 LIKE '%1%' OR field LIKE '%2%' ) AND (field2 LIKE '%1%' OR field2 LIKE '%2%')

unfortunately this query doesn’t give me good result since i get back rows which doesn’t match my idea 🙂

for example if checkboxes values 1,2,3,4,5,6,7 are selected by user
query need to return only 1, 3 and 5th row

is there any better solution for filtering this results

regards

Additional Info:

Let me try to explain you a little bit more the idea
User check chekboxes with some values (ie. 1,3,4,5,6,7) script need to return only results which contain those values in field1 same thing happens when user check other checkboxes which control field2 and field3 but for now it’s not important

Additional info pt2.

I’ll try to give you all better explanation what i want to achieve

I have search form with checkboxes and radio input fields, each checkbox group ( values from 1 to 10 ) are represent columns ( field1, field2, field3 ) in table, each value in columns field1 for example represent selected checkboxes ( which are set in admin panel for each row ) now by default all check boxes are selected and i get all results now when user deselect respective checkbox results need to be filtered up with rows according to filter
good example what i try to achieve is http://www.hotelscombined.com/City/London.htm

so if checkbox with value 2 is deselected it can’t be listed in results

BR
Sile

  • 1 1 Answer
  • 2 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-23T17:12:11+00:00Added an answer on May 23, 2026 at 5:12 pm

    I think the problem is that %1% matches not only 1 but also 10, 11, etc.

    It’s better to do something like this:

    WHERE CONCAT(':', field1, ':') LIKE '%:1:%'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a legacy mysql database and there's this table which has a few
I have a database table (named Topics) which includes these fields : topicId name
I have a few classes, such as those that outline database table structure or
I have a database table and one of the fields (not the primary key)
I have a database table called Posts which stores all the information regarding an
I have a database table with a large number of rows and one numeric
I have 3 text files each of which contains a list of 20 items.
I have a table with a few relational columns and one XML column which
In my database, I have a few columns in one of my tables that
I have a database table that i want to allow my friends to update.

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.