这就是我加入2个表格并选择表格的方式:
OleDbDataAdapter DataA = new OleDbDataAdapter(@"Select tfr.FeedID, tf.FeedName, tfr.FeedQuantity, tf.DM
FROM tFeeds AS tf
INNER JOIN tFeedsRations AS tfr ON (tf.FeedID=tfr.FeedID)", Connection);
但是将访问查询添加到此select命令呢?
例如,我想将此语句添加到我的选择命令中:
Select qfq.FeedDMQuantites
From qFeeds_Quantities as qfq
我该怎么办?
最佳答案
好吧,在此表JOIN
中添加另一个qFeeds_Quantities
条件(假设您与此表或其他表之间的公共列有关系)。
假设您在此新表中还有一个公共列,例如FeedID
,则可以创建另一个JOIN
select tfr.FeedID, tf.FeedName, tfr.FeedQuantity,
tf.DM, qfq.FeedDMQuantites
FROM (tFeeds AS tf
INNER JOIN tFeedsRations AS tfr ON tf.FeedID = tfr.FeedID)
INNER JOIN qFeeds_Quantities as qfq ON tf.FeedID = qfq.FeedID;
如果要包含另一个
JOIN
,请加上括号FROM ((tFeeds AS tf
INNER JOIN tFeedsRations AS tfr ON tf.FeedID = tfr.FeedID)
INNER JOIN qFeeds_Quantities as qfq ON tf.FeedID = qfq.FeedID)
INNER JOIN BLAH AS bll ON bll.test = tf.test;