Showing posts with label tabels. Show all posts
Showing posts with label tabels. Show all posts

Monday, March 19, 2012

how can build two tabels together with ms sql query

Hello to all,

I have now two tabels ( Ta and Tb). the tabel includes difference attributte. I want to build this two tables together.

I used this query:

select * from Ta where Ta.Id = @.ID union all select * from Tb where Tb.IdOfa = @.ID

but it doesn't work and the following error message comes

"All inquiries in an SQL application, which contain a union operator, must contain directly many expressions in their goal lists "

Can someone help me?

Thanks

best Regards

pinsha

Please post some sample data from each table and the result you are expecting out of your query.|||

Hi Pinsha,

While using Union Operator you must have the equal number of columns in both query.

You have written Select * Query 1 Union Select * Query 2

Please check if the number of columns are same in both the queries. ( I mean in both the tables as they are used in queries )

Satya

|||

satya_tanwar:

Please check if the number of columns are same in both the queries. ( I mean in both the tables as they are used in queries )

And the columns should be ofsimilardatatype.

|||

Off Course Bro...Stick out tongue

Satya