这是我如何加入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命令:
Select qfq.FeedDMQuantites
From qFeeds_Quantities as qfq
我该怎么办?
答案 0 :(得分:5)
在此表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;