Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
amitbadgi
Starting Member
29 Posts |
Posted - 2005-08-07 : 22:05:10
|
| Hi guys, just wanted to know what was wrong with this sql query, as it is giving me an error, using this query in a vb.net application against an access database, rs_user.Source = "SELECT tblUsers.id, tblUsers.userid, tblUsers.firstname, tblUsers.lastname, tblUsers.user_type, tblLKP_User_Type.usertypename,tblLKP_User_Access.useraccessname, tblUsers.active, tblUsers.last_login, tblLKP_Department.deptname, tblUsers.viewallcase,tblUsers.department FROM (tblUsers INNER JOIN tblLKP_User_Access ON tblUsers.user_access = tblLKP_User_Access.useraccessid) INNER JOIN (tblLKP_User_Type ON tblUsers.user_type = tblLKP_User_Type.usertypeid) INNER JOIN (tblLKP_Department ON tblUsers.department = tblLKP_Department.deptid) WHERE (tblUsers.active = 'Y') ORDER BY tblLKP_Department.deptname, tblUsers.lastname"Thanks in advance |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2005-08-07 : 22:53:52
|
| Remove your parentheses in your FROM clause. You don't need these in SQL Server, only Access (sometimes)Tim |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-08 : 01:23:46
|
>>just wanted to know what was wrong with this sql query, as it is giving me an error, When asking question, it is better to post the error also so that others can easily identify where you were wrong MadhivananFailing to plan is Planning to fail |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2005-08-08 : 02:17:03
|
quote: Originally posted by timmy Remove your parentheses in your FROM clause. You don't need these in SQL Server, only Access (sometimes)Tim
He is querying access.-ec |
 |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2005-08-08 : 02:22:28
|
quote: Originally posted by eyechart
quote: Originally posted by timmy Remove your parentheses in your FROM clause. You don't need these in SQL Server, only Access (sometimes)Tim
He is querying access.-ec
OOps |
 |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2005-08-08 : 02:28:09
|
Did you build this query yourself, or did you do it using the Query Wizard?Access does funny things with it's query nesting. Probably the best thing to do is start with 2 tables, then gradually add the next tables one by one testing each time.Access does seem to want parantheses to separate your joins, so here's the approach I normally take:SELECT a.field1, b.field2, c.field3, d.field3FROM ((tableA a INNER JOIN tableB b ON a.id = b.id) INNER JOIN tableC c ON b.newID = c.newID) INNER JOIN tableD d ON c.anotherID = d.anotherID This is much easier to read than the way Access does things. It's also much easier for people to debug....Tim |
 |
|
|
|
|
|
|
|