Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 how to jion this two tables

Author  Topic 

jeff06
Posting Yak Master

166 Posts

Posted - 2011-10-26 : 09:48:19
table t1
select distinct ["a"]
from t1

i got
"a"
"01"
"02"
"03"
Strange every thing has "" on it.


I tried to run
select distinct ["a"]
from t1
where ["a"]='01'

I get no record return.
How can I make it return "01"?
Thanks.

jeff06
Posting Yak Master

166 Posts

Posted - 2011-10-26 : 09:51:06
I also need to join table t2

select distinct a from t2

will return
a
01
02


select t1.*
from t1, t2
on t1.["a"]=t2.a

How to make it work?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-26 : 13:50:05
quote:
Originally posted by jeff06

table t1
select distinct ["a"]
from t1

i got
"a"
"01"
"02"
"03"
Strange every thing has "" on it.


I tried to run
select distinct ["a"]
from t1
where ["a"]='01'

I get no record return.
How can I make it return "01"?
Thanks.





select distinct ["a"]
from t1
where ["a"]='"01"'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-26 : 13:52:26
quote:
Originally posted by jeff06

I also need to join table t2

select distinct a from t2

will return
a
01
02


select t1.*
from t1, t2
on t1.["a"]=t2.a

How to make it work?



select t1.*
from t1
join t2
on t1.["a"]='"' + t2.a + '"'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -