2

this is how i join 2 tables and select form it:

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);

but what about adding a access query to this select command? for example I want to add this statement to my select command:

Select qfq.FeedDMQuantites
From qFeeds_Quantities as qfq

what should I do?

1 Answer 1

5

Well add another JOIN condition to this table qFeeds_Quantities (assuming you have a relationship to this table or a common column among other table).

Assuming you have a common column like FeedID in this new table as well you can make another JOIN like

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;

If you want to include another JOIN then parenthesize like

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;
Sign up to request clarification or add additional context in comments.

5 Comments

tanks but this is what i've qot: Additional information: Syntax error (missing operator) in query expression '(tf.FeedID=tfr.FeedID)
( cc: @SaraniO ) The Access Database Engine is going to want parentheses around one of those INNER JOINs, e.g., ... FROM (foo INNER JOIN bar ON ...) INNER JOIN baz ON .... It's "an Access thing".
@GordThompson tanks, would you please show it on my code? because I add parantheses around one of them and it gives me Syntax error in FROM clause.
@Rahul Tanks a lot, it worked, Now what about if I want to add another join condition to this? what should I do?
@SaraniO, increase the parenthesis like see edit ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.