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.
| 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.UserCommentsWHERE Weblog.blogID = MMColParam2ORDER BY blogDate DESCvariable name = MMColParam2variable default value = 0variable 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 aJOIN dbo.UserComments b ON a.BlogID = b.BlogIDWHERE a.blogID = MMColParam2ORDER BY blogDate DESC[/CODE]Duane. |
 |
|
|
-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- |
 |
|
|
|
|
|