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)
 inner join query help

Author  Topic 

-Dman100-
Posting Yak Master

210 Posts

Posted - 2004-09-16 : 23:50:08
I have the following query:

SELECT *
FROM dbo.Weblog, dbo.UserComments
WHERE Weblog.blogID = MMColParam2
ORDER BY blogDate DESC

variable name = MMColParam2
variable default value = 0
variable Run-Time value = Request.QueryString("blogID")

I'm trying to return the records that have the same blogID in both tables. I created a one to many relationship between the two tables using the primary key field "blogID" in the Weblog table and a foreign key field "blogID" in the UserComments table. The above query returns all records in the UserComments table instead of returning the records associated by a specific "blogID" number.

I'm not sure, is the querystring value in a URL string a character string value? The data type for the field "blogID" in both tables is an integer. Could that be the problem? I wasn't sure if that could be what is causing the problem? Do I need to convert the value to an integer? If that is the problem, how do I make the conversion to an integer in the query?

Or, is the problem something else related to the query?

Thanks for any help!
-D-

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-09-16 : 23:56:32
[CODE]
SELECT *
FROM dbo.Weblog a
JOIN dbo.UserComments b
ON a.BlogID = b.BlogID
WHERE a.blogID = MMColParam2
ORDER BY blogDate DESC
[/CODE]


Duane.
Go to Top of Page

-Dman100-
Posting Yak Master

210 Posts

Posted - 2004-09-17 : 00:27:54
Thanks Duane,

Worked perfectly! I'm still in the very novice stages of learning SQL and I'm not very proficient with joins. I really appreciate your help.

Thanks,
-D-
Go to Top of Page
   

- Advertisement -