从表中获取数据的问题 [英] Problem to fetch the datas from table

查看:81
本文介绍了从表中获取数据的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的表中有以下记录

In my table has following records

Menuid  Menuname         Navigation URL              ParentID
1	Company Details 	#	             11
101	Create Company	NewCompany.aspx?id=	      1
2	Branch Details	#	                     11
201	Create Branch	NewBranch.aspx?id=	      2
4	Menu List	MenuList.aspx?id=	     11
5	Administrator	#	                     11
6	Master   	#	                   NULL
601	Ledger Group	LedgerGroup.aspx?id=	      6
603	Item	          #	                      6
6031	New Item	NewItem.aspx?id=	    603
604	Ledger   	#                       	6
6041	New Ledger	NewLedger.aspx?id=	     604
7	Entry	         #               	    NULL
606	Price List	#	                       6
6061	Item Wise Price List	NewPWPrice	     606
6062	Party Wise Price List	NewIWPrice	     606
701	Purchase	#	7
7011	New Purchase	NewPurchase.aspx?id=	    701
702	Sales	         #	                      7 
7021	New Sales	NewSales.aspx?id=	         702
7022	Alter Sales	AlterSales.aspx?id=      	702
7014	Display 	DisplayPurchase.aspx	        701
704	Purchase Return	#	          7
7041	Create Return	NewPurchaseReturn.aspx?id=	704
703	Sales Return	#	7
7031	Create Return	NewSalesReturn.aspx?id=  	703


在上面的这张表中,我要检查menuid列中是否存在所有的parentid

怎么做?请帮助我


In this above table I want to check the all the parentid exists in menuid column

How to do it? Please help me

推荐答案

select parentid  from tbl where parentid  not in (select menuid from tbl)





使用不存在



or

use not exists

select parentid  from tbl where not exists (select menuid from tbl)


这篇关于从表中获取数据的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆