创建数据库表格
CREATE TABLE `message` (
`message_id` int(5) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(200) NOT NULL,
`content` text NOT NULL,
PRIMARY KEY (`message_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
`message_id` int(5) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(200) NOT NULL,
`content` text NOT NULL,
PRIMARY KEY (`message_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
select * from message where message_id =1;
select * from message where title like '%a%';
%表示占位符,在a的左边和右边都有信息;
插入信息
INSERT INTO MESSAGE(TITLE,CONTENT) VALUES ('NIHAO','MYSQL');
删除信息
DELETE FROM MESSAGE WHERE MESSAGE_ID = 3;
升序排列
select * from message order by message_id asc;
降序排列
select * from message order by message_id desc;
更新信息
update message set title ='nihao2',content = 'mysql2' where message_id = 2;
翻页
升序排列从第一条开始的前5条
select * from message order by message_id asc limit 0,5;
select * from message order by message_id asc limit 5,5;