从表中选择记录的问题 [英] Problem for selecting records from table
问题描述
在我的表中有以下内容
Ledger_Transaction_hdr
In my table has following
Ledger_Transaction_hdr
Lth_comp LTH_SNO Lth_ledgerid Lth_trantype lth_total lth_paid lth_received
3 7 1 PR 10000 10000 0
3 7 5 PR 2000 0 10000
3 8 1 SR 2000 10000 0
3 8 15 SR 3000 0 10000
3 5 3 SL 10000 10000 0
3 5 4 SL 1000 0 10000
3 5 5 SLRCPT 1200 1200 0
3 5 5 SLRCPT 1200 0 1200
在上表中,我想详细了解 LEDGER ID 1 ,如下所示:
IN THE ABOVE TABLE I WANT TO DETAILS FOR LEDGER ID 1 like following
Lth_comp LTH_SNO Lth_ledgerid Lth_trantype lth_total lth_paid lth_received
3 7 5 PR 2000 0 10000
3 8 15 PR 3000 0 10000
如何获得它,我给了ledgerid 1
它根据 lth_sno 的操作从1返回交易,请帮助我任何人,谢谢您
如果我给这个查询
how to get it I give the ledgerid 1
it returns the transaction from 1 depending on lth_sno how to do it please help me anybody thankyou
If i give this query
Select * from ledger_transaction_hdr where lth_Transrlno in (select lth_transrlno from ledger_transaction_hdr where lth_ledgerid=1)
它给人以为是
It give the folloing
Lth_comp LTH_SNO Lth_ledgerid Lth_trantype lth_total lth_paid lth_received
3 7 5 PR 2000 0 10000
3 8 15 PR 3000 0 10000
3 5 5 SLRCPT 1200 1200 0
3 5 5 SLRCPT 1200 0 1200
但是我不想那样.我想要First Solutions
But I don''t want like that. I want First Solutions
推荐答案
我认为您正在寻找其join
.在这里看看:
http://msdn.microsoft.com/en-us/library/ms191517%28v = sql.105%29.aspx [ ^ ]
祝你好运!
I think itsjoin
you are looking for. Have a look here:
http://msdn.microsoft.com/en-us/library/ms191517%28v=sql.105%29.aspx[^]
Good luck!
select * from ledger_transaction_hdr a where lth_sno in (Select lth_sno from ledger_transaction_hdr where lth_ledger_id=1)
或
从存在的ledger_transaction_hdr中选择*(从ledger_transaction_hdr中选择lth_sno,其中lth_ledger_id = 1)
or
select * from ledger_transaction_hdr a where exists (Select lth_sno from ledger_transaction_hdr where lth_ledger_id=1)
select * from Ledger_Transaction_hdr where Lth_trantype ='PR' and lth_paid =0
你想要那样的话
you want like that
这篇关于从表中选择记录的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!