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)
 from clause

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-07-30 : 07:54:51
Cristina writes "I have three tables: T_ArticleTypeList(id,art_type), T_ArticlesList(id, type_id,...) and T_Inventory(id, art_id, inventory_id,...)

I want a querry that returned all the articles that are not in a Inventory, and I wrote this :

select distinct T_iArticlesList.id, T_iArticlesList.art_name, T_iArticlesList.art_type_id,
T_iArticleTypeList.art_type_code, T_iArticleTypeList.art_type_name,
T_iArticlesList.art_inv_no,T_iArticlesList.comments
from T_iArticlesList,T_iArticleTypeList,T_iInventory
where (T_iArticlesList.id not in (select T_iInventory.art_id from T_iInventory)) and (T_iArticlesList.art_type_id=T_iArticleTypeList.id)

When table Inventory is empty the querry dosn't return me all the articles. More than that, the querry dosn,t return any article. I want to know why and how can I resolve that problem?"

Amethystium
Aged Yak Warrior

701 Posts

Posted - 2003-07-30 : 08:06:01
[CODE]
SELECT DISTINCT A.ID, A.ART_NAME, A.ART_TYPE_ID,B.ART_TYPE_CODE, B.ART_TYPE_NAME,B.ART_INV_NO,B.COMMENTS
FROM T_IARTICLESLIST AS A
INNER JOIN T_IARTICLETYPELIST AS B
ON A.ART_TYPE_ID = B.ID
WHERE A.ID NOT IN (SELECT ART_ID FROM T_IINVENTORY)
[/CODE]

---------------
Shadow to Light
Go to Top of Page
   

- Advertisement -