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
 General SQL Server Forums
 New to SQL Server Programming
 SQL quiry help needed

Author  Topic 

nick2price
Starting Member

4 Posts

Posted - 2008-04-06 : 17:03:14
I want to use the select function but it is quite hard to explain but i will try. I have created several tables and added all needed constraints on them.
I want to do a querry where i select all events that hire both large and small items. To do this i need to do somthing like

select events from hireSmall and hireLarge

I know thats not right but it gives u an idea. Then The eventNo in The events table is linked with a customer number in the Customer table. So in all, i need to return the event number and customer number. In all, my SQL should look somthing like:

select events (that are in both) from hireSmall and hireLarge, use this events number to get customer details from customer tabel

Any help?

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-04-06 : 17:26:11
something like:

select *
from
(
select events from hireSmall
union all
select events from hireLarge
) AllEvents
join Customers C on AllEvents.CustomerId = C.Id

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page
   

- Advertisement -