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 2000 Forums
 SQL Server Development (2000)
 Problem with queries requiring a condition

Author  Topic 

froggy
Starting Member

14 Posts

Posted - 2006-10-05 : 22:42:00
Hi,
I am currently writing a program which will require it to return results from a table(Details) with information like name, contact number and section.
However i will need to restrict the results to only members of the section based on the section which the login user belongs to.

Eg. If login user belongs to Section(Basketball), when he does a search, it will return him results of only people belonging to Basketball etc.

Thank you.

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2006-10-05 : 22:45:28
I assume you'll have another table containing user login details, so you'll probably need to link these two tables together and then filter based on the user's section.
Without seeing your table design it's difficult to be more specific.

HTH,

Tim
Go to Top of Page

froggy
Starting Member

14 Posts

Posted - 2006-10-05 : 23:01:53
Hi,
i am not veyr usre about linking cos i just started doing programming.
What i have are basically 2 tables, Login and Details

Login has Id and Section fields
Details has Name, Number, Address, Section fields

What i hope to achieve is that should a basketballer log into the system, he will only see details of people falling under Basketball and not the rest from other sports.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-05 : 23:16:14
[code]
select d.*
from login l inner join details d
on l.section = d.section
where l.id = @login_id
[/code]

if the id is same as the SQL Login Id then you can change to

[code]
select d.*
from login l inner join details d
on l.section = d.section
where l.id = system_user
[/code]


KH

Go to Top of Page
   

- Advertisement -