一.动态sql
1.使用if 条件查询
(1) 创建数据库和表
CREATE TABLE `t_blog` (
`id` INT (11),
`title` VARCHAR (765),
`content` VARCHAR (765),
`owner` VARCHAR (150)
);
INSERT INTO `t_blog` (`id`, `title`, `content`, `owner`) VALUES('1','java基础','详细描述','唐国强11');
INSERT INTO `t_blog` (`id`, `title`, `content`, `owner`) VALUES('2','中文','中国','ofo11');
INSERT INTO `t_blog` (`id`, `title`, `content`, `owner`) VALUES('3','html','html标签','样式');
INSERT INTO `t_blog` (`id`, `title`, `content`, `owner`) VALUES('6','html','www','eee');
INSERT INTO `t_blog` (`id`, `title`, `content`, `owner`) VALUES('9','中文','111','1111');
(2)实体类Blog
public class Blog {
private int id;
private String title;
private String content;
private String owner;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {