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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:08:47+00:00 2026-06-03T20:08:47+00:00

Is it possible to have a wildcard in a column name specified in the

  • 0

Is it possible to have a wildcard in a column name specified in the WHERE clause? I want to select something but only if a bunch of columns match a certain value (1 in this case). For example:

SELECT COUNT(id) FROM records WHERE *_check = 1

I have a bunch of columns that have _check as the suffix and it would be really nice to use something similar to the above code (which doesn’t work).

  • 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-03T20:08:49+00:00Added an answer on June 3, 2026 at 8:08 pm

    You could query the information_schema to get the columns in one query

    SELECT column_name FROM information_schema.columns
    WHERE table_schema = 'foo'
     AND table_name = 'bar'
     AND column_name LIKE '%_check'
    

    and build your query from the result (pseudo code)

    query = "SELECT COUNT(id) FROM records WHERE ";
    
    foreach columName in columnNames
       query = query + " " + column_name + " = 1 OR "
    next
    
    query = TrimLastOr(query);
    

    But I wouldn’t recommend that because mysql information_schema query have a poor performance since they read from disk for every query.

    Better: Use a view that returns

    SELECT id FROM records WHERE col1_check=1 or col2_check=2 ...
    

    so you can use it in your logic on multiple places, and only have to update the view if you add another _check column.

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

Sidebar

Related Questions

Is it possible have two projects with the same name in flex builder? Here
Possible Duplicate: MySQL wildcard in select … SELECT icon_* FROM images WHERE 1 I
Ok, stupid question and I don't think it's possible but, I have this markup
I have a bunch of HTML code where I want to remove all the
I want to have a SQL table with two columns. One is a key
Is it possible to set up exclusion/inclusion filters in profiler to have wildcard character
is possible to have a separator between elements of a GridView? Thanks
Is it possible to have an association mapping a table to itself? e.g. Table:
Is it possible to have a relationship from a user table to a system
Is it possible to have multiple classes that inherit/extends same class in Google AppEngine

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.