Atitit. MSSQL SQL Server conversion MySQL and paging SQL AST build
1. Main conversions :: function Conversion , paging conversion 1
2. Ideas :: MSSQL SQL >>ast>>mysql 1
3. the main SQL is as follows ::: 1
4. Mssql2mysqlconvertor (proj:wechatadm4propt 2
1. The main conversion::Conversion of Functions,Paging Conversion2. Ideas:: MSSQL SQL >>ast>>mysql3. sqlthe main following:::
Author :: Old Wow's paw attilax ayron, email:[email protected]
Reprint please indicate source: Http://blog.csdn.net/attilax
SELECT GroupID,
GroupName
CONVERT (varchar, createtime, +) as Createtime,
Weixinusercount,
Remark
From
(SELECT row_number () over (ORDER by Createtime DESC) as RowNum, D1.group Id
D1.groupname,
D1.createtime,
D1.remark,
(SELECT count (D2. UserID)
From T_mb_weixinuser D2
WHERE d2.groupid=d1.groupid) as Weixinusercount
From T_mb_group D1
WHERE 1=1)
As groups
WHERE RowNum between 1 and 10
4.Mssql2mysqlconvertor (proj:wechatadm4propt
Public class mssql2mysqlconvertor {
@Inject
SqlAstBuilderP32 astbldr;
SqlAstP32 ast;
/**
* @author Attilax The claws of old Wow
* @since p33 j_t_37
*/
public   static   void   main ( string [] args ) {
String txt = filex. Read (pathx. ClassPath () + "/mssql1.sql" );
txt = Strutil . Replaceenterchar2space (txt);
txt = txt . ReplaceAll ("row_number.*,"", " ");
Mssql2mysqlconvertor x = new mssql2mysqlconvertor();
String sql_mysql = x. Convert (txt);
System . out . println (JsonX. toJsonStrO88 (x. AST ));
System . out . println (sql_mysql);
}
/**
* @author Attilax The claws of old Wow
* @return
* @since p33 m_j_45
*/
private   string   convert ( string txt ) {
String page_s = strutil. Find ("rowNum (. +) between.+and.+$", txt). Get (0)
. toString ();
page_s = Strutil . Replacedoublespace (page_s);
String [] a = page_s. toUpperCase (). Trim (). Split ("between");
String [] a2 = a[1]. toLowerCase (). Trim (). Split ("and");
Sqlpageparam p = new sqlpageparam();
p . startindex  =  integer parseint ( a2 [ Span style= "COLOR: #ff0ff" >0 ]. trim ()) - 1
P . pagesize = Integer . parseint (A2[1]. Trim ());
AST = New SqlAstP32();
AST . Preother = txt . substring (0, txt. ) indexOf (page_s));
AST . Pagepart = P ;
if (ast. Preother . Trim (). toLowerCase (). EndsWith ("where"))
AST . Preother = AST . Preother + "1=1" ;
return ast. Preother + "Limit" + P . StartIndex + "," + P . pagesize ;
}
Atitit. MSSQL SQL Server conversion MySQL and paging SQL AST build