Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Sql question

Sql question

Scheduled Pinned Locked Moved Database
databasequestionperformancehelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pankajdaga
    wrote on last edited by
    #1

    Hi everyone, Using access, I try to run the following SQL: SELECT (Select Values from AnotherTable) FROM MyQuery MyQuery returns a set of data and I want to filter it further by selecting only the records that are returned by the sub-select. However, this does not work. Are such select queries illegal. Is it not possible to tell it the column names for select through another select query? Is there any workaround for it, rather than creating the string in memory and manually concatenating each column name. An SQL solution would be nice. I would really appreciate some help on this one. Thanks, Pankaj Without struggle, there is no progress

    N 1 Reply Last reply
    0
    • P pankajdaga

      Hi everyone, Using access, I try to run the following SQL: SELECT (Select Values from AnotherTable) FROM MyQuery MyQuery returns a set of data and I want to filter it further by selecting only the records that are returned by the sub-select. However, this does not work. Are such select queries illegal. Is it not possible to tell it the column names for select through another select query? Is there any workaround for it, rather than creating the string in memory and manually concatenating each column name. An SQL solution would be nice. I would really appreciate some help on this one. Thanks, Pankaj Without struggle, there is no progress

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Is this what you are trying to SELECT values FROM Table WHERE somefield IN (SELECT values FROM AnotherTable) Search MSDN for subquery

      P 1 Reply Last reply
      0
      • N Not Active

        Is this what you are trying to SELECT values FROM Table WHERE somefield IN (SELECT values FROM AnotherTable) Search MSDN for subquery

        P Offline
        P Offline
        pankajdaga
        wrote on last edited by
        #3

        Hi there, Actually here is a more clear description of what I am trying to do. Sorry to be vague earlier. In a Select statement you can specify the columns that you want to display. Example, Select FirstName, LastName from PeopleTable. What I am trying to do is this: I have a table (say PeopleTable) that has many columns...say LastName, FirstName, Data Of Birth, Occupation etc. Now, I have another table that is filled by another process that tells me which columns to display: say, example, LastName, FirstName... So what I wanted to do was: SELECT (Select Values from AnotherTable) FROM PeopleTable Select Values from AnotherTable would return LastName and FirstName and my query would be: SELECT(LastName, FirstName) from PeopleTable. However, I guess SQL does not do such syntactic substitution. Does anyone know a way to achieve this. I do not want to use a string and concatenate each of the choices, if there is a way to achieve this with SQL. Thanks a lot :-) Sincerely, Pankaj Without struggle, there is no progress

        J 1 Reply Last reply
        0
        • P pankajdaga

          Hi there, Actually here is a more clear description of what I am trying to do. Sorry to be vague earlier. In a Select statement you can specify the columns that you want to display. Example, Select FirstName, LastName from PeopleTable. What I am trying to do is this: I have a table (say PeopleTable) that has many columns...say LastName, FirstName, Data Of Birth, Occupation etc. Now, I have another table that is filled by another process that tells me which columns to display: say, example, LastName, FirstName... So what I wanted to do was: SELECT (Select Values from AnotherTable) FROM PeopleTable Select Values from AnotherTable would return LastName and FirstName and my query would be: SELECT(LastName, FirstName) from PeopleTable. However, I guess SQL does not do such syntactic substitution. Does anyone know a way to achieve this. I do not want to use a string and concatenate each of the choices, if there is a way to achieve this with SQL. Thanks a lot :-) Sincerely, Pankaj Without struggle, there is no progress

          J Offline
          J Offline
          jeff_martin
          wrote on last edited by
          #4

          Without using a string and concating your query together, No, there is no way to do what you want. Sorry.

          P 1 Reply Last reply
          0
          • J jeff_martin

            Without using a string and concating your query together, No, there is no way to do what you want. Sorry.

            P Offline
            P Offline
            pankajdaga
            wrote on last edited by
            #5

            Yeah, that is what I figured after hours of experimenting here. Damn SQL, we need macros here ;P Thanks for replying and making me finally give up so that I can go to bed :) Sincerely, Pankaj Without struggle, there is no progress

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups