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
 Transact-SQL (2000)
 SQL Query

Author  Topic 

mkh
Starting Member

18 Posts

Posted - 2003-05-20 : 05:31:36
I want to write a sql statement to display the following results from 2 tables FOR A particular NO:

-------------------------------------------
NO |CO-ID | CO-NAME | PROJ-ID | PROJ NAME |
-------------------------------------------
1 12 ABC 121 PRJ1OF1
1 12 ABC 122 PRJ1OF2
1 21 XYZ 221 PRJ2OF1
1 22 XYZ 222 PRJ20F2

my tables are:

table company
------------------------
NO | CO-ID | CO-NAME |
------------------------

table project
---------------------------------
NO | CO-ID | PROJ-ID | PROJ-NAME |
---------------------------------

SOLUTION should appear as shown:
can any one give me the exact sql.




Edited by - mkh on 05/20/2003 05:36:07

mr_mist
Grunnio

1870 Posts

Posted - 2003-05-20 : 05:40:21
SELECT
[NO], [CO-ID] , [CO-NAME], [PROJ-ID], PROJ NAME
FROM
company
INNER JOIN project
on project.[no] = company.[no]
and
project.[co-id] = company.[co-id]
WHERE [no] = 1
ORDER BY
[NO], [CO-ID], [CO-NAME]

?


[edit to say I'm not sure if you actually want all those dashes and things, that would really be a job for your presentation layer.]

-------
Moo.

Edited by - mr_mist on 05/20/2003 05:42:24
Go to Top of Page

mkh
Starting Member

18 Posts

Posted - 2003-05-20 : 06:01:19
thks Mr Mist it works expect that you have to give 'table.colname at some places.
yeah those dashes were meant just for clarity.
thats all for now.
bye



Go to Top of Page
   

- Advertisement -