mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
doc: update docs
This commit is contained in:
parent
18b9dece60
commit
63a376ab5e
90
readme.md
90
readme.md
@ -78,7 +78,7 @@ QueryWrapper query = QueryWrapper.create()
|
|||||||
.and(ACCOUNT.USER_NAME.like("zhang").or(ACCOUNT.USER_NAME.like("li")));
|
.and(ACCOUNT.USER_NAME.like("zhang").or(ACCOUNT.USER_NAME.like("li")));
|
||||||
|
|
||||||
// execute SQL:
|
// execute SQL:
|
||||||
// ELECT * FROM tb_account
|
// SELECT * FROM tb_account
|
||||||
// WHERE tb_account.id >= 100
|
// WHERE tb_account.id >= 100
|
||||||
// AND (tb_account.user_name LIKE '%zhang%' OR tb_account.user_name LIKE '%li%' )
|
// AND (tb_account.user_name LIKE '%zhang%' OR tb_account.user_name LIKE '%li%' )
|
||||||
List<Account> accounts = mapper.selectListByQuery(query);
|
List<Account> accounts = mapper.selectListByQuery(query);
|
||||||
@ -96,7 +96,7 @@ QueryWrapper query = QueryWrapper.create()
|
|||||||
.orderBy(ACCOUNT.ID.desc());
|
.orderBy(ACCOUNT.ID.desc());
|
||||||
|
|
||||||
// execute SQL:
|
// execute SQL:
|
||||||
// ELECT * FROM tb_account
|
// SELECT * FROM tb_account
|
||||||
// WHERE tb_account.id >= 100
|
// WHERE tb_account.id >= 100
|
||||||
// AND (tb_account.user_name LIKE '%zhang%' OR tb_account.user_name LIKE '%li%' )
|
// AND (tb_account.user_name LIKE '%zhang%' OR tb_account.user_name LIKE '%li%' )
|
||||||
// ORDER BY tb_account.id DESC
|
// ORDER BY tb_account.id DESC
|
||||||
@ -112,7 +112,7 @@ Page<Account> accountPage = mapper.paginate(5, 10, query);
|
|||||||
QueryWrapper query=new QueryWrapper();
|
QueryWrapper query=new QueryWrapper();
|
||||||
query.select().from(ACCOUNT)
|
query.select().from(ACCOUNT)
|
||||||
|
|
||||||
// SQL:
|
// SQL:
|
||||||
// SELECT * FROM tb_account
|
// SELECT * FROM tb_account
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -122,8 +122,8 @@ query.select().from(ACCOUNT)
|
|||||||
QueryWrapper query=new QueryWrapper();
|
QueryWrapper query=new QueryWrapper();
|
||||||
query.select(ACCOUNT.ID,ACCOUNT.USER_NAME).from(ACCOUNT)
|
query.select(ACCOUNT.ID,ACCOUNT.USER_NAME).from(ACCOUNT)
|
||||||
|
|
||||||
// SQL:
|
// SQL:
|
||||||
// SELECT tb_account.id, tb_account.user_name
|
// SELECT tb_account.id, tb_account.user_name
|
||||||
// FROM tb_account
|
// FROM tb_account
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -137,9 +137,9 @@ QueryWrapper query = new QueryWrapper()
|
|||||||
.from(ACCOUNT.as("a"), ARTICLE.as("b"))
|
.from(ACCOUNT.as("a"), ARTICLE.as("b"))
|
||||||
.where(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID));
|
.where(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID));
|
||||||
|
|
||||||
// SQL:
|
// SQL:
|
||||||
// SELECT a.id, a.user_name, b.id AS articleId, b.title
|
// SELECT a.id, a.user_name, b.id AS articleId, b.title
|
||||||
// FROM tb_account AS a, tb_article AS b
|
// FROM tb_account AS a, tb_article AS b
|
||||||
// WHERE a.id = b.account_id
|
// WHERE a.id = b.account_id
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -154,10 +154,10 @@ QueryWrapper query = new QueryWrapper()
|
|||||||
avg(ACCOUNT.SEX).as("sex_avg")
|
avg(ACCOUNT.SEX).as("sex_avg")
|
||||||
).from(ACCOUNT);
|
).from(ACCOUNT);
|
||||||
|
|
||||||
// SQL:
|
// SQL:
|
||||||
// SELECT tb_account.id, tb_account.user_name,
|
// SELECT tb_account.id, tb_account.user_name,
|
||||||
// MAX(tb_account.birthday),
|
// MAX(tb_account.birthday),
|
||||||
// AVG(tb_account.sex) AS sex_avg
|
// AVG(tb_account.sex) AS sex_avg
|
||||||
// FROM tb_account
|
// FROM tb_account
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -170,10 +170,10 @@ QueryWrapper queryWrapper=QueryWrapper.create()
|
|||||||
.where(ACCOUNT.ID.ge(100))
|
.where(ACCOUNT.ID.ge(100))
|
||||||
.and(ACCOUNT.USER_NAME.like("michael"));
|
.and(ACCOUNT.USER_NAME.like("michael"));
|
||||||
|
|
||||||
// SQL:
|
// SQL:
|
||||||
// SELECT * FROM tb_account
|
// SELECT * FROM tb_account
|
||||||
// WHERE tb_account.id >= ?
|
// WHERE tb_account.id >= ?
|
||||||
// AND tb_account.user_name LIKE ?
|
// AND tb_account.user_name LIKE ?
|
||||||
```
|
```
|
||||||
|
|
||||||
### exists, not exists
|
### exists, not exists
|
||||||
@ -189,11 +189,11 @@ QueryWrapper queryWrapper=QueryWrapper.create()
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// SQL:
|
// SQL:
|
||||||
// SELECT * FROM tb_account
|
// SELECT * FROM tb_account
|
||||||
// WHERE tb_account.id >= ?
|
// WHERE tb_account.id >= ?
|
||||||
// AND EXIST (
|
// AND EXIST (
|
||||||
// SELECT 1 FROM tb_article WHERE tb_article.id >= ?
|
// SELECT 1 FROM tb_article WHERE tb_article.id >= ?
|
||||||
// )
|
// )
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -207,10 +207,10 @@ QueryWrapper queryWrapper=QueryWrapper.create()
|
|||||||
.and(ACCOUNT.SEX.eq(1).or(ACCOUNT.SEX.eq(2)))
|
.and(ACCOUNT.SEX.eq(1).or(ACCOUNT.SEX.eq(2)))
|
||||||
.or(ACCOUNT.AGE.in(18,19,20).or(ACCOUNT.USER_NAME.like("michael")));
|
.or(ACCOUNT.AGE.in(18,19,20).or(ACCOUNT.USER_NAME.like("michael")));
|
||||||
|
|
||||||
// SQL:
|
// SQL:
|
||||||
// SELECT * FROM tb_account
|
// SELECT * FROM tb_account
|
||||||
// WHERE tb_account.id >= ?
|
// WHERE tb_account.id >= ?
|
||||||
// AND (tb_account.sex = ? OR tb_account.sex = ? )
|
// AND (tb_account.sex = ? OR tb_account.sex = ? )
|
||||||
// OR (tb_account.age IN (?,?,?) OR tb_account.user_name LIKE ? )
|
// OR (tb_account.age IN (?,?,?) OR tb_account.user_name LIKE ? )
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -222,8 +222,8 @@ QueryWrapper queryWrapper=QueryWrapper.create()
|
|||||||
.from(ACCOUNT)
|
.from(ACCOUNT)
|
||||||
.groupBy(ACCOUNT.USER_NAME);
|
.groupBy(ACCOUNT.USER_NAME);
|
||||||
|
|
||||||
// SQL:
|
// SQL:
|
||||||
// SELECT * FROM tb_account
|
// SELECT * FROM tb_account
|
||||||
// GROUP BY tb_account.user_name
|
// GROUP BY tb_account.user_name
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -236,9 +236,9 @@ QueryWrapper queryWrapper=QueryWrapper.create()
|
|||||||
.groupBy(ACCOUNT.USER_NAME)
|
.groupBy(ACCOUNT.USER_NAME)
|
||||||
.having(ACCOUNT.AGE.between(18,25));
|
.having(ACCOUNT.AGE.between(18,25));
|
||||||
|
|
||||||
// SQL:
|
// SQL:
|
||||||
// SELECT * FROM tb_account
|
// SELECT * FROM tb_account
|
||||||
// GROUP BY tb_account.user_name
|
// GROUP BY tb_account.user_name
|
||||||
// HAVING tb_account.age BETWEEN ? AND ?
|
// HAVING tb_account.age BETWEEN ? AND ?
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ QueryWrapper queryWrapper=QueryWrapper.create()
|
|||||||
.from(ACCOUNT)
|
.from(ACCOUNT)
|
||||||
.orderBy(ACCOUNT.AGE.asc(), ACCOUNT.USER_NAME.desc().nullsLast());
|
.orderBy(ACCOUNT.AGE.asc(), ACCOUNT.USER_NAME.desc().nullsLast());
|
||||||
|
|
||||||
// SQL:
|
// SQL:
|
||||||
// SELECT * FROM tb_account
|
// SELECT * FROM tb_account
|
||||||
// ORDER BY age ASC, user_name DESC NULLS LAST
|
// ORDER BY age ASC, user_name DESC NULLS LAST
|
||||||
```
|
```
|
||||||
@ -265,10 +265,10 @@ QueryWrapper queryWrapper = QueryWrapper.create()
|
|||||||
.leftJoin(ARTICLE).on(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID))
|
.leftJoin(ARTICLE).on(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID))
|
||||||
.where(ACCOUNT.AGE.ge(10));
|
.where(ACCOUNT.AGE.ge(10));
|
||||||
|
|
||||||
// SQL:
|
// SQL:
|
||||||
// SELECT * FROM tb_account
|
// SELECT * FROM tb_account
|
||||||
// LEFT JOIN tb_article
|
// LEFT JOIN tb_article
|
||||||
// ON tb_account.id = tb_article.account_id
|
// ON tb_account.id = tb_article.account_id
|
||||||
// WHERE tb_account.age >= ?
|
// WHERE tb_account.age >= ?
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -283,30 +283,30 @@ QueryWrapper queryWrapper = QueryWrapper.create()
|
|||||||
.limit(10)
|
.limit(10)
|
||||||
.offset(20);
|
.offset(20);
|
||||||
|
|
||||||
// MySql:
|
// MySql:
|
||||||
// SELECT * FROM `tb_account` ORDER BY `id` DESC LIMIT 20, 10
|
// SELECT * FROM `tb_account` ORDER BY `id` DESC LIMIT 20, 10
|
||||||
|
|
||||||
// PostgreSQL:
|
// PostgreSQL:
|
||||||
// SELECT * FROM "tb_account" ORDER BY "id" DESC LIMIT 20 OFFSET 10
|
// SELECT * FROM "tb_account" ORDER BY "id" DESC LIMIT 20 OFFSET 10
|
||||||
|
|
||||||
// Informix:
|
// Informix:
|
||||||
// SELECT SKIP 20 FIRST 10 * FROM "tb_account" ORDER BY "id" DESC
|
// SELECT SKIP 20 FIRST 10 * FROM "tb_account" ORDER BY "id" DESC
|
||||||
|
|
||||||
// Oracle:
|
// Oracle:
|
||||||
// SELECT * FROM (SELECT TEMP_DATAS.*,
|
// SELECT * FROM (SELECT TEMP_DATAS.*,
|
||||||
// ROWNUM RN FROM (
|
// ROWNUM RN FROM (
|
||||||
// SELECT * FROM "tb_account" ORDER BY "id" DESC)
|
// SELECT * FROM "tb_account" ORDER BY "id" DESC)
|
||||||
// TEMP_DATAS WHERE ROWNUM <=30)
|
// TEMP_DATAS WHERE ROWNUM <=30)
|
||||||
// WHERE RN >20
|
// WHERE RN >20
|
||||||
|
|
||||||
// Db2:
|
// Db2:
|
||||||
// SELECT * FROM "tb_account" ORDER BY "id" DESC
|
// SELECT * FROM "tb_account" ORDER BY "id" DESC
|
||||||
// OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY
|
// OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY
|
||||||
|
|
||||||
// Sybase:
|
// Sybase:
|
||||||
// SELECT TOP 10 START AT 21 * FROM "tb_account" ORDER BY "id" DESC
|
// SELECT TOP 10 START AT 21 * FROM "tb_account" ORDER BY "id" DESC
|
||||||
|
|
||||||
// Firebird:
|
// Firebird:
|
||||||
// SELECT * FROM "tb_account" ORDER BY "id" DESC ROWS 20 TO 30
|
// SELECT * FROM "tb_account" ORDER BY "id" DESC ROWS 20 TO 30
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -97,7 +97,7 @@ QueryWrapper query = QueryWrapper.create()
|
|||||||
.and(ACCOUNT.USER_NAME.like("张").or(ACCOUNT.USER_NAME.like("李")));
|
.and(ACCOUNT.USER_NAME.like("张").or(ACCOUNT.USER_NAME.like("李")));
|
||||||
|
|
||||||
// 执行 SQL:
|
// 执行 SQL:
|
||||||
// ELECT * FROM tb_account
|
// SELECT * FROM tb_account
|
||||||
// WHERE tb_account.id >= 100
|
// WHERE tb_account.id >= 100
|
||||||
// AND (tb_account.user_name LIKE '%张%' OR tb_account.user_name LIKE '%李%' )
|
// AND (tb_account.user_name LIKE '%张%' OR tb_account.user_name LIKE '%李%' )
|
||||||
List<Account> accounts = accountMapper.selectListByQuery(query);
|
List<Account> accounts = accountMapper.selectListByQuery(query);
|
||||||
@ -116,7 +116,7 @@ QueryWrapper query=QueryWrapper.create()
|
|||||||
.orderBy(ACCOUNT.ID.desc());
|
.orderBy(ACCOUNT.ID.desc());
|
||||||
|
|
||||||
// 执行 SQL:
|
// 执行 SQL:
|
||||||
// ELECT * FROM tb_account
|
// SELECT * FROM tb_account
|
||||||
// WHERE id >= 100
|
// WHERE id >= 100
|
||||||
// AND (user_name LIKE '%张%' OR user_name LIKE '%李%' )
|
// AND (user_name LIKE '%张%' OR user_name LIKE '%李%' )
|
||||||
// ORDER BY `id` DESC
|
// ORDER BY `id` DESC
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user