Showing posts with label subquery. Show all posts
Showing posts with label subquery. Show all posts

Monday, March 19, 2012

How to edit a subquery in query designer

Hello!

Is it possible to edit a subquery in the diagram and grid pane,without using the texteditor in the SQL pane?

The way i do it now (hopefully not the best way):
1 Create a tmp dataset with sql statement for the subquery
2 Rightclick in the original dataset and "Add a new derived tables"
4 Paste the sql code from tmp query to the original dataset.

After linking the original query with many subquerys, it is difficult to change any off the subquerys!

Best Regards

Hello,

Currently, Query Designer does not support designing sub-queries via Diagram Pane or Criteria Pane. Our team has been working on enabling the design time support for sub-queries and we hope to include it in future versions of Visual Studio.

Thanks!

Wednesday, March 7, 2012

How to do this?

I know how to use IN with WHERE clause but it does the OR on all values in the subquery. The question is how to make it match against all values returned?

ex:

SELECT UserID FROM UserCars WHERE CarID IN (10,20,30)

would return user ids of all users that have a either car 10, 20 OR 30

How to write simple query to get users that have cars 10, 20 AND 30

thanks,where CarID between 10 and 30

otherwise

where CarID = 10 and CarID = 20 and CarID = 30 and CarID = 10000001|||hmm, so there is really no other statement like IN that would do AND instead of OR on subquery?

i tried using ALL but that didnt work :/|||select u.UserID
from Users u
where exists(select 'x' from UserCars uc1 where u.UserID=uc1.UserID and uc1.CarID=10)
and exists(select 'x' from UserCars uc2 where u.UserID=uc1.UserID and uc1.CarID=20)
and exists(select 'x' from UserCars uc2 where u.UserID=uc1.UserID and uc1.CarID=30)

OR

select UserID
from UserCars
where CarID in (10,20,30)
group by UserID
having count('x')=3