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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:57:27+00:00 2026-05-23T21:57:27+00:00

There are two tables, the first contain data and the second meta data for

  • 0

There are two tables, the first contain data and the second meta data for the first based on category.

table1 
id, category1, category2, custom1, custom2, custom3...

table2 
category1, category2, denom, field

Example:

table1
AAAAA, Car, Compact, Red, Automatic, 150bhp

table2
Car, Compact, Color, custom1

The ‘field’ column in table2 points to which field in table1 we have meta data for.

Now what I am looking to do is to somehow use the value of the ‘field’ column in an sql as the column.

select * from table1
where table1.category1 = 'Car'
  and table1.category2 = 'Compact'
  and table1.category1 = table2.category1
  and table1.category2 = table2.category2
  and table2.denom = 'Color'
  and table1.(value of table2.field) = 'Red'

Is this possible to do in a single sql statement?

  • 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-23T21:57:28+00:00Added an answer on May 23, 2026 at 9:57 pm

    It is possible if you know the number of “custom” columns in advance.

    you can replace

    and table1.(value of table2.field) = 'Red'
    

    with

    and    case table2.field
             when 'custom1' then table1.custom1
             when 'custom2' then table1.custom2
             when 'custom3' then table1.custom2
             ...
             else NULL
           end
           = 'Red'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am comparing between two tables first column each. If there is find a
There are two databases and 4 tables involved in this query. The first database(PhoneBills)
There are two tables. One is users info users, one is comments info comments.
alt text http://img502.imageshack.us/img502/7245/75088152.jpg There are two tables that I join them together, one of
I need to merge two SELECT statements. There are two tables in my database,
One doubt in MSSQL. There are two tables in a databases. Table 1 named
I am developing a student registration form in asp.net. there are two tables viz
There is a store procedure that uses FREETEXTTABLE twice on two tables and then
We have two tables in a SQL Server 2005 database, A and B.There is
I have two tables Plants and Information. For every plant there are many information,

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.