Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2003
    Posts
    8

    Unanswered: ASP.NET SQL LEFT JOIN error

    Hi,
    got a problem with an ASP.NET (vbscript) page thats driving me mad!

    My SQL query is:

    SELECT TOP 100 person.first_name, person.last_name, person_type.type FROM person LEFT JOIN person_type ON person.person_ref = person_type.person_ref ORDER BY last_name

    it was a lot more complex but i simplfied it down to just one join to try and figure the problem, which is that it causes this error....

    Exception Details: Microsoft.Data.Odbc.OdbcException: ERROR [42000] [Sybase][ODBC Driver][Adaptive Server Anywhere]Syntax error or access violation: near 'JOIN' in ...FROM person LEFT [JOIN] (person_type ON...

    Ive pasted the query into access and it works fine and if I replace the LEFT for INNER it also works fine.


    Any suggestions would be much appriciated as its driving me crazy!


    D

  2. #2
    Join Date
    Jul 2003
    Location
    Ohio/Chicago
    Posts
    75
    joins will be different upon which DB you're using
    Code:
    select select_list 
    from table1 {left | right} [ outer] join
            table2
    on  predicate 
     [ join restriction]
    For example:

    Code:
    select au_fname, au_lname,  pub_name
    from authors left join publishers
    on  authors.city = publishers.city

  3. #3
    Join Date
    Aug 2003
    Posts
    8
    So you mean the syntax for doing a join on a sybase db will be different than for doing it in access?

  4. #4
    Join Date
    Jul 2003
    Location
    Ohio/Chicago
    Posts
    75
    possibly, i try to avoid access like the plague, but left/right join's can be a pain because they tend to differ langauge to language, does anyone know if there's a SQL standard way?

  5. #5
    Join Date
    Aug 2003
    Posts
    8
    Might be some use to someone in future so....

    I eventually found out that all i needed to do was add OUTER in between in LEFT and JOIN

  6. #6
    Join Date
    Jul 2003
    Location
    Ohio/Chicago
    Posts
    75
    or you could have read my first post and seen the outer keyword there =P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •