Results 1 to 10 of 10
  1. #1
    ron2794 is offline Member
    Join Date
    Dec 2010
    Posts
    38
    Rep Power
    0

    Default javadb syntax error

    i am using javadb and using the following line in it and

    i am using the natural command and the javadb is saying that natural is a syntax error , kindly tell me how it can be a syantax error.

    I used the following line as :
    select AccessionNumber, b , c from app.ab natural join app.bookinfo

    Actually , i am having AccessionNumber as the common field in both the tables.

    kindly tell me any another way if it is not possible this way.

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Because "natural join" is not part of the SQL standards. inner join, left outer join, right outer join, full outer join, cross join. Those are the SQL standard join forms.

    Edit: P.S. where in the SQL Syntax manual that comes with the JavaDB download did you find reference to "natural join"?

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by masijade View Post
    Edit: P.S. where in the SQL Syntax manual that comes with the JavaDB download did you find reference to "natural join"?
    I wonder too.

  4. #4
    gandrew is offline Member
    Join Date
    Nov 2010
    Posts
    5
    Rep Power
    0

    Default

    Dear Sir: A Natural Join exists in Javadb (Derby) and in mySQL. For other interested parties, the link to the Javadb join documentation can be found here. Derby Reference Manual

    One possible problem might be in the table names. You are using: select AccessionNumber, b , c from app.ab natural join app.bookinfo.

    Try this: select AccessionNumber, b , c from ab natural join bookinfo

    I am basing this syntax on a similar relationship of tables I am using in MySQL. It would take about an hour to describe this, so I'm going to skip it.

    Why use a Natural Join? (From "Learning PHP & MySQL", Davis, Phillips, O'Reilly Publishing, 2006, p. 141) "You can specify the NATURAL JOIN keyword to accomplish the same query with less typing. With natural joining, MySQL can take two tables and automatically join the fields that have the same name... the natural join is smart enough not to display title_id twice (found in both databases) and ...etc.

    As pointed out, there are alternatives, but the concept exists. If you are still stuck include more information, database structure and so forth. Sincerely--G.O.
    Last edited by gandrew; 01-02-2011 at 10:36 PM.

  5. #5
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default

    Good God.
    That's evil!

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  7. #7
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default

    Relying on consistent naming across tables.
    That way lies madness.

    ETA: sSpecifically the idea that an id column on a table should be named something other than "id".

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  9. #9
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default

    True.
    But then some people also think the world is flat...
    ;)

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. lexical error in javadb
    By ron2794 in forum JDBC
    Replies: 1
    Last Post: 12-16-2010, 11:27 AM
  2. sql select ,error in your SQL syntax
    By miko5054 in forum JDBC
    Replies: 13
    Last Post: 06-28-2010, 11:48 AM
  3. No more syntax error
    By ideyatech in forum Java Software
    Replies: 2
    Last Post: 04-22-2010, 04:20 AM
  4. Syntax error on token
    By egun in forum New To Java
    Replies: 4
    Last Post: 02-11-2010, 10:57 AM
  5. syntax error
    By gabriel in forum New To Java
    Replies: 3
    Last Post: 08-03-2007, 03:26 PM

Posting Permissions

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