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 2005 Forums
 Transact-SQL (2005)
 Combine 2 select quyers

Author  Topic 

IBoonZ
Yak Posting Veteran

53 Posts

Posted - 2009-11-27 : 12:18:47
hi :D
I got following code

select

(CONVERT(VARCHAR(50),boeken.uitg_id)+
CONVERT(VARCHAR(50),boeken.cat_id)) as BUitCaID,
uitgever,
titel
from boeken
left join uitgever
on uitgever.uitg_id = boeken.uitg_id)



select
(CONVERT(VARCHAR(50),uitg_id) +
CONVERT(VARCHAR(50),cat_id) )as UitCaID,
uitgever.uitgever,
categorie.categorie
from categorie,uitgever


Now, what i Need is to Combine the 2 querys with eachother.
THe Id to join them is BUitCaID and UitCaID.

Is that possible?

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2009-11-27 : 12:29:43
convert both fields to "text" on the fly and then proceed.

select (convert(cola, char(3)) + convert (colb, char(4)) from mytable

i'm rushing home now, so play around with the syntax of the convert....
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-27 : 22:22:56
[code]
select *
from
(
select

(CONVERT(VARCHAR(50),boeken.uitg_id)+
CONVERT(VARCHAR(50),boeken.cat_id)) as BUitCaID,
uitgever,
titel
from boeken
left join uitgever
on uitgever.uitg_id = boeken.uitg_id)

)t1
join
(
select
(CONVERT(VARCHAR(50),uitg_id) +
CONVERT(VARCHAR(50),cat_id) )as UitCaID,
uitgever.uitgever,
categorie.categorie
from categorie,uitgever
)t2
on t2.UitCaID=t1.BUitCaID
[/code]
Go to Top of Page

IBoonZ
Yak Posting Veteran

53 Posts

Posted - 2009-11-28 : 05:24:24
Hmm, I get incorrect syntax neer the )t1 and )t2,
I tried also )as t1, but doesent work :)
Go to Top of Page

IBoonZ
Yak Posting Veteran

53 Posts

Posted - 2009-11-28 : 05:33:04
Ow, found it, :) a ')' too much in select 1 ty :D
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-28 : 05:43:46
welcome
Go to Top of Page
   

- Advertisement -