Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hello, I have three tables and each table has a common attribute named "indate" and whenever i"m trying to join three tables using the following query it gives me an error "Syntax error in FROM clause". please solve my problem. Thanks.....
OleDbCommand cm = new OleDbCommand("SELECT payment.indate,payment.opening_balance,payment.purpose,payment.amount,income.indate,income.opening_balance,income.purpose,income.amount,bank_dep.indate,bank_dep.balance_opening,bank_dep.bank,bank_dep.amount FROM payment INNER JOIN income,bank_dep ON payment.indate=income.indate=bank_dep.indate",cn);
 
[Edit]Code block added[/Edit]
Posted 19-Feb-13 7:50am
Edited 19-Feb-13 7:56am
ProgramFOX131.8K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

FROM payment INNER JOIN income,bank_dep
 
You can have more tables in FROM, like: FROM payment,income,bank_dep, but you can't have other than one single table after JOIN, and you have two. And you never can have an operation like a=b=c, but you have You need to split the statement across multiple joins:
SELECT payment.indate,payment.opening_balance,payment.purpose,payment.amount,income.indate,income.opening_balance,income.purpose,income.amount,bank_dep.indate,bank_dep.balance_opening,bank_dep.bank,bank_dep.amount 
FROM (payment 
INNER JOIN income ON payment.indate=income.indate)
INNER JOIN bank_dep ON income.indate=bank_dep.indate
  Permalink  
v2
Comments
Maciej Los at 19-Feb-13 13:21pm
   
+5!
Chiklu.Soumya at 19-Feb-13 13:40pm
   
it gives an error "syntax error(missing operator) in query expression 'payment.indate=income.indate INNER JOIN bank_dep on income.indate=bank_dep.indate"
Zoltán Zörgő at 19-Feb-13 15:44pm
   
Sorry, Access is non-standard, it requires some parenthesis. See updated query.
Chiklu.Soumya at 19-Feb-13 22:08pm
   
Thanks A lot. Now it's working fine.
Zoltán Zörgő at 20-Feb-13 3:26am
   
You are welcome. Feel free to accept my answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 200
1 George Jonsson 175
2 Kornfeld Eliyahu Peter 169
3 PIEBALDconsult 110
4 Richard MacCutchan 85
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100