Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 24th, 2006, 04:01 PM
Authorized User
Join Date: Sep 2006
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with SELECT INTO statement

What is wrong with this code?
    $con = mysql_connect("mysql157.secureserver.net","132591","lotrt2t");
        die("Hey, you with the eyes, check your connection.");


    $sql = "CREATE TABLE backupuser(
                user varchar(12),
                password varchar(12)
    mysql_query($sql, $con);

    $sql = "SELECT * INTO backupuser FROM users ";
    mysql_query($sql, $con);
The SELECT * INTO userbackup FROM users is not working. It acts as though I did not even put it there.

"Judge a man by his questions, not by his answers."
\"Judge a man by his questions, not by his answers.\"
Old November 27th, 2006, 06:58 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post

SELECT INTO always creates a TABLE that is of the structure of the Columns put up in the SELECT INTO statement. But you seem to create the destination table and then use the SELECT INTO, that is why it is erring out.

If the table already exists, you should use INSERT INTO, instead of SELECT INTO. INSERT INTO, inserts the resulting rows in to an existing table.

Hope that clarifies.

- Vijay G
Strive for Perfection

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Bie- Select Statement problem sparsh2010 Access VBA 1 January 22nd, 2008 01:00 PM
SQL select statement problem shrisangeeta Classic ASP Databases 3 June 15th, 2006 10:28 AM
Problem with "where = " select statement shirley65 SQL Language 3 October 17th, 2005 04:07 PM
Problem with select statement s.abraham ASP.NET 1.0 and 1.1 Basics 2 March 24th, 2005 02:29 PM
SELECT statement...strange problem abbylee26 Classic ASP Databases 7 March 16th, 2004 02:34 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.