This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin Cookbook and have Ken Kousen on-line!
See this thread for details.
Win a copy of Kotlin Cookbook this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

how can we use where clause with insert query using preparedStatement?

 
Ranch Hand
Posts: 214
Netbeans IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,


I want to insert value from a table into anoother how it is possible to insert with where caluse


my query is below:



and I want in this----

cat is the dynamic.........

thank you.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your insert statement should look like

Insert into tab1(column list) SELECT val1, val2,........ FROM tab2 WHERE ........... ;
Make sure your SELECT returns correct data types for the tab1 in the same order as column list.
 
Rd Dari
Ranch Hand
Posts: 214
Netbeans IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is in this ......




out put is here ;;;;


I tried a lot but not done

please correct this syntax error
 
Sudheer Bhat
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your SQL query should look like Insert into tab1(column list) SELECT val1, val2,........ FROM tab2 WHERE ........... ;
 
Rd Dari
Ranch Hand
Posts: 214
Netbeans IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but as I need some field extra in history_grocery and some missing from grocery

it this case what i should do???

like..


and

some values are come using ajax and js in view(jsp page)like quantity and total_amount....
 
Sudheer Bhat
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can actually pass all the values which are coming from view to the SQL statement. If you need to select one field from another table and other 10 values coming from view then your SELECT part of INSERT statement would look like SELECT ?,?,?........., col1, col2 FROM table where ....
You would set the values which you retrieved from the view using statement.set... methods.
 
I'm full of tinier men! And a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!