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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:27:36+00:00 2026-05-13T23:27:36+00:00

Ok, here was my original question; Table one contains ID|Name 1 Mary 2 John

  • 0

Ok, here was my original question;

Table one contains

ID|Name  
1  Mary  
2  John  

Table two contains

ID|Color  
1  Red  
1  Blue
2  Blue  
2  Green  
2  Black  

I want to end up with is

ID|Name|Red|Blue|Green|Black  
1  Mary Y   Y  
2  John     Y     Y     Y

It seems that because there are 11 unique values for color and 1000’s upon 1000’s of records in table one that there is no ‘good’ way to do this. So, two other questions.

Is there an efficient way to query to get this result? I can then create a crosstab in my application to get the desired result.

ID|Name|Color  
1  Mary  Red  
1  Mary  Blue  
2  John  Blue  
2  John  Green  
2  John  Black

If I wanted to limit the number of records returned how could I do a query to do something like this?

Where ((color='blue') AND (color<>'red' OR color<>'green'))

So using the above example I would then get back

ID|Name|Color  
1  Mary  Blue  
2  John  Blue  
2  John  Black

I connect to Visual FoxPro tables via ADODB to use SQL. 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-13T23:27:37+00:00Added an answer on May 13, 2026 at 11:27 pm

    From your prior question, and querying against a VFP table, you could get your results by
    the following VFP qualified query… cross-tab complete

    select
          N.ID,
          N.Name,
          MAX( IIF( C.Color = "Red", "Y", " " )) Red,
          MAX( IIF( C.Color = "Blue", "Y", " " )) Blue,
          MAX( IIF( C.Color = "Green", "Y", " " )) Green,
          MAX( IIF( C.Color = "Black", "Y", " " )) Black
       FROM
          C_Names N,
          Colors C
       WHERE
          N.ID = C.ID
       GROUP BY 
          N.ID,
          N.Name
    

    Then, as you have other “colors”, just copy the MAX( IIF()) for that respective color and have the column as the result column name… follow the pattern. Only issue is if you have different case-sensitve spelling of the colors, then you may need to UPPER( C.Color ) = “RED” (or similar for other colors)

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

Sidebar

Related Questions

This question is sort of a follow-up to my original question here . Let's
My original question can be found here , for which I've gotten some great
Original question: here Upon searching i need to alter the results across rows which
Original Question: Database Design: need composite key + foreign key Here's what I need:
The original question is here.. MySQL self-referencing ID and selects I would like to
REVISED QUESTION (SEE BELOW FOR ORIGINAL): Here is an example of a simple ajax
Refer original post here for a reference to the original issue. What plugin should
here is the original code: public static int getInt () { Scanner in =
Let's say I have some original text: here is some text that has a
I'm trying to parallelize a convolution function in C. Here's the original function which

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.