• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create Temporary Table in MySQL

 
hob hartman
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working in a JSP.
I would like to create a temporary table in MySQL database using a select statement( it is a right join). But I cannot figure out the query statement in Java.
Here is the MySQL documentation: CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
[table_options] [select_statement]
My select_statement is "SELECT * FROM Titles RIGHT JOIN Publishers ON Titles.PubID=Publishers.PubID"
I have tried the executeUpdate method with a "CREATE TABLE" statement as an argument but keep getting a SQL syntax runtime error.
I have also tried nesting SELECT statements as I can do in Access but apparently MySQL has to have temporary tables created separately.
Hope this is clear enough. Would love to see an example of how to create the temp table using a select statement.
hob
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hob goblin
Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic