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 |
|
paradise_wolf
Starting Member
32 Posts |
Posted - 2007-02-21 : 09:03:32
|
| How to use EXISTS instead INNER JOIN in the below procedure ?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ALTER PROCEDURE GetProductsOnPromotInDep( @DepartmentID INT)ASSET NOCOUNT ONSELECT DISTINCT Product.ProductID, TitleFROM ProductINNER JOIN ProductCategory ON ProductCategory.ProductID = Product.ProductIDINNER JOIN Category ON Category.CategoryID = ProductCategory.CategoryIDINNER JOIN Department ON Department.DepartmentID = Category.DepartmentIDWHERE Category.DepartmentID = @DepartmentID AND Product.OnPromotion = 1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-21 : 09:05:05
|
you have to explain what you want the query to do ? KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
paradise_wolf
Starting Member
32 Posts |
Posted - 2007-02-21 : 09:22:52
|
| Hi khtan and Peso{{you have to explain what you want the query to do ?}}I want to get the list of products that obey these conditions, collect them in a DataTable and display them in a DataList control in a web page ( C# )whenever the user clicks a button.Regarding the SQL database tables, there is a relation of “one to many” between 'Department' and 'Category', “one to many” between 'Category' and 'ProductCategory', “many to one” between 'ProductCategory' and 'Product'. |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-02-21 : 10:08:31
|
| The main question here is WHY YOU WANT TO DO IT? Just to know it can be done or you are facing some performance problem with your existing query or something else?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
paradise_wolf
Starting Member
32 Posts |
Posted - 2007-02-21 : 11:00:45
|
| {{The main question here is WHY YOU WANT TO DO IT? Just to know it can be done or you are facing some performance problem with your existing query or something else?}}Not really, Harsh. I don’t even deployed the web site yet ( actually I don’t even finish it ) but since I was told that using “EXISTS” is better ( probably for performance reasons ) and I am still learning SQL, it would be wise to learn how to use a code for best performance. That is why I want to learn it. |
 |
|
|
|
|
|