Create a table with a space in the name in mySQL

后端 未结 2 820
猫巷女王i
猫巷女王i 2020-12-11 05:35

I want to create a table in mySQL with the name of \"123 Product\", with numbers in the beginning and a space in between. I can do this using phpmyAdmin but I want to make t

相关标签:
2条回答
  • 2020-12-11 05:41

    Another solution, when the other did not work

    $query = "SELECT * 
                From \`base\x20hojas\`";
    

    Configuration test :

    • PHP Version 5.5.9-1 Ubuntu 4.11
    • Linux version 2.6.32-32-pve (gcc version 4.7.2 (Debian 4.7.2-5) )

      Description: Ubuntu 14.04.1 LTS
      Release:     14.04
      Codename:    trusty
      
    • Apache Version 2.4.7 (Ubuntu)
    • MySQL 5.1.30-community; 5.1.30-community;
    0 讨论(0)
  • 2020-12-11 06:02

    You can simply try this: enclose table name with backticks (`)

    $sql = "
    CREATE TABLE `123 Product` 
    (
    `product_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    `product_name` VARCHAR(255) NOT NULL
     ) 
    ENGINE = InnoDB;
    ";
    
    0 讨论(0)
提交回复
热议问题