Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 24th, 2006, 04:01 PM
Authorized User
 
Join Date: Sep 2006
Location: , , .
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with SELECT INTO statement

What is wrong with this code?
Code:
<?php
    $con = mysql_connect("mysql157.secureserver.net","132591","lotrt2t");
    if(!con){
        die("Hey, you with the eyes, check your connection.");
    }

     mysql_select_db("132591");

    $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."
-Voltaire
__________________
\"Judge a man by his questions, not by his answers.\"
-Voltaire
Reply With Quote
  #2 (permalink)  
Old November 27th, 2006, 06:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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.
Cheers.

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:13 PM.


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