The moose likes JDBC and the fly likes Create  Temporary Table in MySQL Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JDBC
Reply Bookmark "Create  Temporary Table in MySQL" Watch "Create  Temporary Table in MySQL" New topic
Author

Create Temporary Table in MySQL

hob hartman
Greenhorn

Joined: Mar 04, 2002
Posts: 11
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

Joined: May 10, 2001
Posts: 3244
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!!


Dave
 
 
subject: Create Temporary Table in MySQL
 
Threads others viewed
query consisting of if statements, looping, cases on mysql?
ejb-ql question (extending the constraint in an outer join)
Hibernate session
JDBC Execute Method not working as expected
how to create MySql stored procedure?
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com