Sql question
-
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
-
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
Is this what you are trying to SELECT values FROM Table WHERE somefield IN (SELECT values FROM AnotherTable) Search MSDN for subquery
-
Is this what you are trying to SELECT values FROM Table WHERE somefield IN (SELECT values FROM AnotherTable) Search MSDN for subquery
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
-
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
Without using a string and concating your query together, No, there is no way to do what you want. Sorry.
-
Without using a string and concating your query together, No, there is no way to do what you want. Sorry.
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