"John Raines" <com> wrote in message
news:net...
Would it be possible to replace the mismatch fields with placeholder
variables to satisfy the UNION statement?
Hello- I am working on a small web project, and I have 3 queries that look like this: select * from table1; select * from table2; select * from table3; table1 had 3 columns, table2 has 4 columns, and table3 has 5 columns. Unfortunately, due to poor design I can not at this time change the query syntax of these;however, I would like to add a UNION statement to them. Again, poor design dictates that the UNION statement be the same for each of these queries. Of course the problem is the number of columns is different. Is there any ...
Hello-
I am working on a small web project, and I have 3 queries that look like
this:
select * from table1;
select * from table2;
select * from table3;
table1 had 3 columns, table2 has 4 columns, and table3 has 5 columns.
Unfortunately, due to poor design I can not at this time change the query
syntax of these;however, I would like to add a UNION statement to them.
Again, poor design dictates that the UNION statement be the same for each of
these queries.
Of course the problem is the number of columns is different. Is there any
possible way I can use an ISNULL or something similar to determine the
number of columns returned by my UNION statement? I am only concerned with
the data UNION'd in the 1st column, and am just returning 0's for the rest,
like:
UNION name,0,0
If I could dynamically add columns with values of 0 within the SQL, that
would work.
Like I said, this is poor design (it is *not* mine!) but I can't change
these things at this time - but I am working towards it!
Thanks
John
"John Raines" <com> wrote in message
news:net...
Would it be possible to replace the mismatch fields with placeholder
variables to satisfy the UNION statement?
"Bosconian" <com> wrote in message
news:com...
>
> Would it be possible to replace the mismatch fields with placeholder
> variables to satisfy the UNION statement?
>[/ref]
Do you mean in the original SQL query? As of right now I am unable to modify
it, which really s I know, but I have no choice at the moment.
"John Raines" <com> wrote in message
news:net...
>>
>> Would it be possible to replace the mismatch fields with placeholder
>> variables to satisfy the UNION statement?
>>[/ref]
>
>
> Do you mean in the original SQL query? As of right now I am unable to
> modify it, which really s I know, but I have no choice at the moment.
>
>
>[/ref]
Oh, I thought you could change the query, but not the database schema.
In that case the only thing you can do is merge the data at the code level.
That's a pain, but doable.
Bookmarks