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
 General SQL Server Forums
 New to SQL Server Programming
 SELECT Problem

Author  Topic 

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2010-12-03 : 04:14:19
Hi,

I have a select statement that results more than 1 rows.

Here is the statemt
select Tasks.IsApproved from Tasks,Tasks_Grup where Tasks.grup = Tasks_Grup.id and Tasks.IsApproved = 0 and Tasks.approver like '%abc%' or Tasks.deputy = 'abc'

Result is
IsApproved
1
0

But I would like to GET ONLY IsApproved 0 and i should join those two tables as well. (Tasks and Tasks_Grup)

Thanks in advance.

Best Regards

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-12-03 : 04:21:54
quote:
Originally posted by raysefo

Hi,

I have a select statement that results more than 1 rows.

Here is the statemt
select Tasks.IsApproved from Tasks,Tasks_Grup where Tasks.grup = Tasks_Grup.id and Tasks.IsApproved = 0 and (Tasks.approver like '%abc%' or Tasks.deputy = 'abc')

Result is
IsApproved
1
0

But I would like to GET ONLY IsApproved 0 and i should join those two tables as well. (Tasks and Tasks_Grup)

Thanks in advance.

Best Regards





No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2010-12-03 : 04:28:17
Did you reply webfred?
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-12-03 : 04:33:15
select Tasks.IsApproved -- should this be Tasks.*
from Tasks
join Tasks_Grup
on Tasks.grup = Tasks_Grup.id
where Tasks.IsApproved = 0
and (Tasks.approver like '%abc%' or Tasks.deputy = 'abc')



==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-12-03 : 04:39:32
quote:
Originally posted by raysefo

Did you reply webfred?


Yes I did.
See the red marked parentheses...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2010-12-03 : 04:45:58
thanks so much for both of you :)
Go to Top of Page
   

- Advertisement -