Monday, March 19, 2012

Joining more than one table

Hai,
I need the query for joining more than one table in views without
using where condition in sqlserver.Can anyone help me?
Looking frward for ur reply...
Thanx in advancePrince
SELECT <column lists> FROM Table1 JOIN Table2
ON Table1.pk=Table2.pk JOIN Table3 ON
Table1.pk=Table3.pk
But ,why don't you need a WHERE condition?
"Prince" <princevictor.moses@.gmail.com> wrote in message
news:1123762724.429184.8090@.g49g2000cwa.googlegroups.com...
> Hai,
> I need the query for joining more than one table in views without
> using where condition in sqlserver.Can anyone help me?
> Looking frward for ur reply...
> Thanx in advance
>|||Well, without more specific information,
SELECT t1.*, t2.*, t3.*
FROM Table1 t1
INNER JOIN Table2 t2
ON t1.key = t2.key
INNER JOIN Table3 t3
ON t2.key = t3.key
"Prince" <princevictor.moses@.gmail.com> wrote in message
news:1123762724.429184.8090@.g49g2000cwa.googlegroups.com...
> Hai,
> I need the query for joining more than one table in views without
> using where condition in sqlserver.Can anyone help me?
> Looking frward for ur reply...
> Thanx in advance
>|||hai Uri Dimant,
i dont much about sqlserver...
i need a query without that ON condition bcoz my cloumns of first
table is not present in columns of second table and vice versa... can i
use union if yes please tell me how?
Thanx..|||hai Aaron Bertrand,
i dont much about sqlserver...
i need a query without that ON condition bcoz my cloumns of first
table is not present in columns of second table and vice versa... can i
use union if yes please tell me how?
Thanx..|||Prince
I'm not sure what you are doing ,so try this
SELECT col1,col2 FROM Table1
UNION ALL
SELECT col3,col4 FROM Table2
"Prince" <princevictor.moses@.gmail.com> wrote in message
news:1123764221.132592.18440@.g43g2000cwa.googlegroups.com...
> hai Uri Dimant,
> i dont much about sqlserver...
> i need a query without that ON condition bcoz my cloumns of first
> table is not present in columns of second table and vice versa... can i
> use union if yes please tell me how?
> Thanx..
>|||hai Uri Dimant ,
what u gave works fine...
but in this case it is showing error
SELECT * FROM Table1
UNION ALL
SELECT * FROM Table2
Thanx|||> i need a query without that ON condition bcoz my cloumns of first
> table is not present in columns of second table and vice versa...
Then how do you expect to join them? Maybe you could start by showing us
your table structure, some sample data, and desired results. Please check
out http://www.aspfaq.com/5006 for some help on the most effective way to do
this...|||> but in this case it is showing error
> SELECT * FROM Table1
> UNION ALL
> SELECT * FROM Table2
What is the error? What does Table1 look like? What does Table2 look like?
If these tables are unrelated and have different column structures, why on
earth do you need to union them? Can't your application deal with more than
one resultset?|||Prince
Perhapa a number of columns in Table1 is not the same as in Table2. It is
always a good practice not to use SELECT * statement ,particular in
production.
"Prince" <princevictor.moses@.gmail.com> wrote in message
news:1123765429.665606.217850@.g47g2000cwa.googlegroups.com...
> hai Uri Dimant ,
> what u gave works fine...
> but in this case it is showing error
> SELECT * FROM Table1
> UNION ALL
> SELECT * FROM Table2
> Thanx
>

No comments:

Post a Comment