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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:33:43+00:00 2026-05-19T12:33:43+00:00

Table1 has the following columns problem t1 t2 t1 and t2 are INT problem

  • 0

Table1 has the following columns

problem
t1
t2

t1 and t2 are INT

problem is the result of the values from t1,t2

t1 can be 1,2,3,4,5
t2 can be 6,7,8,9,10

I could write an SQL query that says

SELECT * from Table1 WHERE (t1=1 OR t1=2 OR t1=3 OR t1=4 OR t1=5) AND (t2=6 OR t2=7 OR t2=8 OR t2=9 OR t2=10)

But instead of writing out the entire expression (shown above), I want to store it into another table (called Table2)

Table2 has the following columns
data_entered
data_results

data_entered is 1
data_results is a string with the following data “(t1=1 OR t1=2 OR t1=3 OR t1=4 OR t1=5)”

data_entered is 2
data_results is a string with the following data “(t2=6 OR t2=7 OR t2=8 OR t2=9 OR t2=10)”

so I want to create a QUERY where I could say

SELECT * from Table1 WHERE … (and specify data_entered) the results should be the same as the above mentioned SQL.

Please help.

Thanks

  • 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-05-19T12:33:44+00:00Added an answer on May 19, 2026 at 12:33 pm

    For your first query, you can use IN instead:

    select * from table1 where t1 in (1,2,3,4,5) and t2 in (6,7,8,9,10);
    

    Then instead of storing sql code in table2, store each value in a seperate row.

    create table data (entered, result);
    insert into data values (1, 1);
    insert into data values (1, 2);
    ...
    insert into data values (2, 10);
    

    Then you can do:

    select *
      from table1
     where t1 in (select result from data where entered = 1)
       and t2 in (select result from data where entered = 2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pictures table that has the following columns: PICTURE_ID int IDENTITY(1000,1) NOT
I've a table [File] that has the following schema CREATE TABLE [dbo].[File] ( [FileID]
I have a HTML file that has code similar to the following. <table> <tr>
I've one interface which has following method signatures: public interface ITag { int M_Id
Am using the following query to get a Client. The Client has a public
I have a query like the following that returns the correct number of rows
I have a table that has several columns: HarvestID, HarvestDate, UserID to mention the
I'm having a small problem making a query in MySQL. I have the following
My Django app has a Person table, which contains the following text in a
I have the following Hibernate Mapping, which has to be mapped using the Table

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.