如何在c#中使用OleDbDataAdaptercommand从2个表中进行选择
本文关键字:2个 选择 行选 OleDbDataAdaptercommand | 更新日期: 2023-09-27 18:04:14
我有一个database
在访问2013,我想从2的表中选择一个命令,这是我的尝试:
OleDbDataAdapter DataA = new OleDbDataAdapter(@"Select FeedName from tFeeds where FeedID IN (Select FeedID from tFeedsRations),
FeedQuantity from tFeedsRations", Connection);
DataTable DTable = new DataTable();
DataA.Fill(DTable);
但是它给出了:
查询表达式'FeedID in (Select FeedID from tFeedsRations)中的语法错误(逗号)
有可能做这样的事情吗?
Select FeedName from tFeeds where FeedID IN (Select FeedID from tFeedsRations), FeedQuantity from tFeedsRations
是无效的SQL。
看起来您正在尝试执行连接,它将按照以下步骤执行。
SELECT tf.FeedName, tfr.FeedQuanity
FROM tFeeds AS tf
INNER JOIN tFeedsRations AS tfr ON (tf.FeedID = tfr.FeedID)