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)
 How can I make this query ?

Author  Topic 

xam
Starting Member

1 Post

Posted - 2002-11-09 : 22:26:04
Hi All,

Here is my problem:
How can I make an SQL query to do this:

Here is the result I'd like to get

NAME ZONE INDEX
---------------------------------------------
ALCATEL EUROPE 2
MICROSOFT AMERICA 1
LOREAL EUROPE 1


I have 4 tables

table 1: ENTITY
-----------------------
entityid (PK) name
----------------------
10 ALCATEL
20 MICROSOFT
30 LOREAL


table 2: TYPE
----------------------------
typeid(PK) name
----------------------------
10 ZONE
20 INDEX

table 3: ENTC
---------------------------------------
entcatid(PK) typeid (FK) name
-----------------------------------
10 10 EUROPE
20 10 AMERICA
30 20 1
40 20 2

table 4: ENTCC

(typeid,entcatid) is the PK
---------------------------------------
entityid(FK) typeid (FK) entcatid(FK)
-----------------------------------
10 10 10
10 20 40
20 10 20
20 20 30
30 10 10
30 20 30

Thanks in advance,
xaxa


Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-11-10 : 02:24:56
Hi there

You need to "JOIN" those tables together.
Look in Books Online (The SQL Server documentation) for the term "INNER JOIN", and read up on that. There will ba some sample queries to help you understand this.

Post back here if you have any questions.

Good luck

Damian
Go to Top of Page
   

- Advertisement -