在mySQL中的名称中创建一个带有空格的表 [英] Create a table with a space in the name in mySQL

查看:452
本文介绍了在mySQL中的名称中创建一个带有空格的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在MySQL中创建一个名称为"123 Product"的表,其开头是数字,中间是空格.我可以使用phpmyAdmin进行此操作,但我想使用php制作此表.但是,不幸的是,我无法做到这一点.我尝试搜索有关此主题的内容,但找不到能够解决问题的准确答案.

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 this table using php. But, unfortunately, I am unable to do this. I tried searching about this topic but I was not able to find an accurate answer which would solve the problem.

推荐答案

您可以尝试以下操作:在表名后加上反引号(`)

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;
";

这篇关于在mySQL中的名称中创建一个带有空格的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆