Home > Backend Development > PHP Tutorial > 为什么插入不了

为什么插入不了

WBOY
Release: 2016-06-23 14:00:41
Original
1412 people have browsed it

-- -- Table structure for table `category`-- CREATE TABLE IF NOT EXISTS `category` (`id` int(11) NOT NULL AUTO_INCREMENT,`catpath` varchar(255) DEFAULT NULL,`name` varchar(255) DEFAULT NULL,PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;-- -- Dumping data for table `category`-- INSERT INTO `category` (`id`, `catpath`, `name`) VALUES(1, '0', '网站首页'),(2, '0-1', 'Linux OS'),(3, '0-1', 'Apache服务器'),(4, '0-1', 'MySQL数据库'),(5, '0-1', 'PHP脚本语言'),(6, '0-1-2', 'Linux 系统教程'),(7, '0-1-2', 'Linux 网络技术'),(8, '0-1-2', 'Linux 安全基础'),(9, '0-1-2-7', 'Linux LAMP'),(10, '0-1-3-10', 'apache Server'); 
Copy after login



INSERT INTO `category` (`id`, (select concat(catpath,'-',id) as abspath from category order by abspath) as abspath, `name`) VALUES(44, '0-1-2-11', '网站首页');
Copy after login
为什么不能插入


回复讨论(解决方案)

Copy after login
Copy after login
Copy after login
Copy after login
INSERT INTO `category` (`id`, `abspath`, `name`) VALUES
(44, '0-1-2-11', '网站首页');
category括号里面是字段啊 你写sql语句干嘛?

Copy after login
Copy after login
Copy after login
Copy after login
INSERT INTO `category` (`id`, `abspath`, `name`) VALUES
(44, '0-1-2-11', '网站首页');
category括号里面是字段啊 你写sql语句干嘛?

插入啊

Copy after login
Copy after login
Copy after login
Copy after login
INSERT INTO `category` (`id`, `abspath`, `name`) VALUES
(44, '0-1-2-11', '网站首页');
category括号里面是字段啊 你写sql语句干嘛?

那我要实现我那个功能怎么插入啊

Copy after login
Copy after login
Copy after login
Copy after login
INSERT INTO `category` (`id`,  `abspath`, `name`) VALUES
(44, '0-1-2-11', '网站首页');
category括号里面是字段啊 你写sql语句干嘛? 算了我还是用最原始的方法了

INSERT INTO `category` (`id`, `catpath`, `name`) VALUES
(44, (select concat(catpath,'-',id) as abspath from category order by abspath) as abspath, '网站首页');
???

不知道想干什么,你的category表里并没有abspath字段。

是否写错,是这个字段catpath呢?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template