#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    10
    Rep Power
    0

    SQL in a Servlet


    The next query donīt run:

    String query = "SELECT AUTHORS.AU_LNAME, AUTHORS.AU_FNAME, TITLES.TITLE, TITLES.PRICE, TITLES.TITLE_ID FROM AUTHORS, TITLEAUTHOR, TITLES" +
    " WHERE TITLES.TITLE_ID = " + parametro + " ORDER BY TITLES.TITLE";

    parametro is a variable.

    This is the message error: Error conexion: java.sql.SQLException: Unexpected token: = in statement [SELECT AUTHORS.AU_LNAME, AUTHORS.AU_FNAME, TITLES.TITLE, TITLES.PRICE, TITLES.TITLE_ID FROM AUTHORS, TITLEAUTHOR, TITLES WHERE TITLES.TITLE_ID == Submit ORDER BY TITLES.TITLE]
  2. #2
  3. No Profile Picture
    Mentat of IX
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Bucuresti / Toronto
    Posts
    112
    Rep Power
    12
    heh , this shold be interesting

    to tell you the trouth , I myself have had some similar problems when joining tables and having to specify tablename.column instead of just column ...

    to fix my problem I just gave unique names to all of my columns and didn't specify the tablename in the JDBC query , however that might not allwais be an option .
  4. #3
  5. Modding: Oracle MsSQL Firebird
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2001
    Location
    Outside US
    Posts
    8,527
    Rep Power
    538
    String query = "SELECT AUTHORS.AU_LNAME, AUTHORS.AU_FNAME, TITLES.TITLE, TITLES.PRICE, TITLES.TITLE_ID FROM AUTHORS, TITLEAUTHOR, TITLES" +
    " WHERE TITLES.TITLE_ID = '" + parametro + "' ORDER BY TITLES.TITLE";
  6. #4
  7. No Profile Picture
    Mentat of IX
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Bucuresti / Toronto
    Posts
    112
    Rep Power
    12
    hmmm , I might be wrong here but i've done quite a few queries without using the ' ' when i'm comparing an integer . I did have such a problem when i was comparing a string but not integers ...

    is title_id an integer or some sort of character type ?

IMN logo majestic logo threadwatch logo seochat tools logo