Find the answer to your Linux question:
Results 1 to 4 of 4
y helo thar I'm having problems creating a new table using SELECT INTO. I was trying it with a PHP script, but on a MySQL prompt it has the same ...
  1. #1
    Just Joined!
    Join Date
    Mar 2008
    Posts
    26

    SQL: Can't create new table with SELECT INTO

    y helo thar

    I'm having problems creating a new table using SELECT INTO. I was trying it with a PHP script, but on a MySQL prompt it has the same effect - it looks for the table and doesn't find it (see below).

    mysql> SELECT * INTO WAN_Gateway_4
    -> FROM `WG4_GigabitEthernet` , WG4_Serial, CPE, WG4_Vrfs
    -> WHERE WG4_GigabitEthernet.VRF = WG4_Vrfs.VRF
    -> AND WG4_Serial.VRF = WG4_Vrfs.VRF
    -> AND CPE.IP_Address = WG4_Vrfs.IP_address
    -> ORDER BY WG4_GigabitEthernet.VRF;
    ERROR 1327 (42000): Undeclared variable: WAN_Gateway_4

    However from reading this usually excellent resource:
    SQL SELECT INTO Statement
    I get the impression a table can be created simply by invoking the command in the first example.

    what am I doing wrong? Is there any way to get around this? I really don't want to have to create the table manually :E

  2. #2
    Linux Newbie raghaven.kumar's Avatar
    Join Date
    Mar 2008
    Location
    Bangalore, India
    Posts
    209

    Post

    Quote Originally Posted by Azrael2 View Post
    -> FROM `WG4_GigabitEthernet` , WG4_Serial, CPE, WG4_Vrfs
    It seems that the quotes are not necessary.

  3. #3
    Just Joined!
    Join Date
    Mar 2008
    Posts
    26
    Wel, they're not necessary per se, but I've hacked phpmyadmin and I'm uusing it as a web front end - it puts them in automatically sometimes. I've just created this table, and it still comes up with the same error

  4. #4
    Just Joined!
    Join Date
    Mar 2008
    Posts
    26
    Found out how to do it - apparantly what I wanted to do isn't supported in MySQL. It's:
    INSERT INTO [tablename]
    SELECT [fields]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...