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)
 Query problem

Author  Topic 

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2008-04-11 : 03:44:41
problem is to handle relation between table,view and parameter for ongoing test.

I want ProID,ProDescription from samplePro table,the ProID need to different from ProID in view(vw_temppro),then userid in vw_temppro must same the parameter brought from previous page.

This is my query:
"select ProID,ProblemDescription,ProblemResolution from dbo.samplePro where proid not in(select proid from dbo.vw_temppro) and uid=" + userid

I've got error :Invalid columnname uid
Any help!!!!!!

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-11 : 04:35:57
Is the column name uid or userid? Post the definition of samplePro table.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2008-04-11 : 04:45:32
samplePro(ProID,ProblemDescription,ProblemResolution)

this is view:

CREATE VIEW dbo.vw_temppro
AS
SELECT dbo.TempAns.UserID AS uid, dbo.samplePro.ProID AS proid, dbo.TempAns.ProblemAnswer AS proansw, dbo.TempAns.Chk,
dbo.sampleUser.UserName AS uname, dbo.samplePro.ProblemDescription AS prodesc
FROM dbo.TempAns INNER JOIN
dbo.samplePro ON dbo.TempAns.ProblemID = dbo.samplePro.ProID INNER JOIN
dbo.sampleUser ON dbo.TempAns.UserID = dbo.sampleUser.UserID



Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-11 : 04:53:02
I see that uid column belongs to vw_temppro and not samplePro table. So the query should be like:

"select ProID,ProblemDescription,ProblemResolution from dbo.samplePro where proid not in(select proid from dbo.vw_temppro where uid=" + userid + ")"




Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2008-04-11 : 05:01:00
with ur query,i've got error:
"Incorrect syntax near the keyword 'and'"
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-11 : 05:05:12
Please see corrected post.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2008-04-11 : 05:14:59
Thanks Harsh,

now works well.
Go to Top of Page
   

- Advertisement -