|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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 . |
|
#3
|
||||
|
||||
|
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";
__________________
My blog Tutorials about OSS databases, DBMonster ... Contribute to OSS Development, fill bug reports! Developer Shed eSupport Commented my.ini/my.cnf (ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins Random data (with a bias) |
|
#4
|
|||
|
|||
|
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 ? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > SQL in a Servlet |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|