本文介绍了如何从2个表中选择VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嗨所以我用下表得到了这个数据库 表1: Hi so i got this database with the following tablesTABLE 1:--------------------------------------|REF|ID_RECIEVED|ID_DATE|POA|POA_DATE||-------------------------------------|001|YES | |YES| ||002|YES | |NO | |-------------------------------------- 表2: TABLE 2:------------------------------|REF|CRED_NAME|COB|ACCEPTANCE|------------------------------|001|AFRICAN |YES|YES ||001|NEDBANK |YES|YES ||002|NEDBANK |YES|YES |------------------------------ 所以基本上从表1开始,只有一个Ref,但是表2可以有重复 我想要做的是,我想显示所有Refs Where(表1) )ID_RECIEVED,POA和FROM(表2)COB,接受是肯定的 我正在使用带有ms访问数据库的vb.net并且不知道从哪里开始 b $ b 我尝试了什么: 不知道怎么办,但是任何帮助都是有用的So basically from table 1, there can only be one Ref but table 2 can have duplicatesWhat i want to do is, i want to display all Refs Where(TABLE 1) ID_RECIEVED,POA and FROM (TABLE 2) COB,ACCEPTANCE is yesI am using vb.net with a ms access database and got no idea where to startWhat I have tried:Not sure how to do it, but any help would be usefull推荐答案 目前还不清楚你的外键是什么。对我来说,它看起来像REF专栏,所以我会按照这个假设。 你在VB代码中使用的SQL查询将是 It isn't clear what your foreign key is. To me it looks like REF column so i'll go with that assumption.Your SQL query to use in your VB code would beSELECT * FROM Table1 AS AJOIN Table2 AS B ON B.REF = A.REFWHERE A.ID_RECEIVED = 'YES' AND A.POA = 'YES' AND B.COB = 'YES' AND B.ACCEPTANCE = 'YES' 在.net中执行sql。 如何:创建并执行返回行的SQL语句 [ ^ ] 如果你需要VB中的更多帮助,一个简单的谷歌搜索将返回大量链接,为你提供大量的例子。Executing sql in .net.How to: Create and Execute an SQL Statement that Returns Rows[^]If you need more help with that in VB, a simple google search will return plenty of links that will provide you tons of examples. 尝试: Try:SELECT b.REF, a.ID_RECIEVED, a.ID_DATE, A.POA, A.POA_DATE b.CRED_NAME FROM Table2 bJOIN Table1 a ON a.REF = b.REFWHERE b.COB='YES' AND b.ACCEPTANCE='YES' 这篇关于如何从2个表中选择VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-23 08:34