createTabSql = "CREATE TABLE people
(\n" +
" id
int(11) NOT NULL AUTO_INCREMENT,\n" +
" name
varchar(45) COLLATE utf8mb4_bin NOT NULL,\n" +
" age
int(11) NOT NULL,\n" +
" phone
varchar(13) COLLATE utf8mb4_bin NOT NULL,\n" +
" create_date
datetime DEFAULT CURRENT_TIMESTAMP,\n" +
" PRIMARY KEY (id
)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin";
homelandCreateTabSql = "CREATE TABLE homeland
(\n" +
" id
int(11) NOT NULL AUTO_INCREMENT,\n" +
" uid
int(11) NOT NULL,\n" +
" prov
varchar(45) COLLATE utf8mb4_bin DEFAULT NULL,\n" +
" city
varchar(45) COLLATE utf8mb4_bin DEFAULT NULL,\n" +
" town
varchar(45) COLLATE utf8mb4_bin DEFAULT NULL,\n" +
" code
varchar(45) COLLATE utf8mb4_bin DEFAULT NULL,\n" +
" PRIMARY KEY (id
)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin";
dbType = JdbcConstants.MYSQL;
repository = new SchemaRepository(dbType);
repository.console(createTabSql);
repository.console(homelandCreateTabSql);
String sql = "select * from people as p, (select uid,prov,city from homeland order by uid limit 10) as h where p.id=h.uid and p.id = 3 order by p.id limit 100";
List statements = SQLUtils.parseStatements(sql,dbType);
repository.resolve(statements.get(0),SchemaResolveVisitor.Option.ResolveAllColumn);
System.out.println(TestUtils.output(statements));
打印的的sql里没有表h的字段
输出如下:
SELECT p.id
, p.name
, p.age
, p.phone
, p.create_date
FROM people p, (
SELECT uid, prov, city
FROM homeland
ORDER BY uid
LIMIT 10
) h
WHERE p.id = h.uid
AND p.id = 3
ORDER BY p.id
LIMIT 100
暂无答案!
目前还没有任何答案,快来回答吧!