Connect to SQL Server in thinkphp6 and report errors using subquery
sentence
Print SQL statements
Mysql
SELECT `NickName`,`Gender`,`Mobile`,`RealName`,`Birthday` FROM `SiteCustomerSupplement` `s` INNER JOIN `WxUser` `u` ON `u`.`OpenId`=`s`.`OpenId` WHERE `s`.`OpenId` IN (SELECT DISTINCT `OpenId` FROM `WxPackagesOrder` WHERE `OrderStatus` >= 40 AND `RegionId` = 72) AND `Birthday` BETWEEN '2021-10-26' AND '2021-11-02'
SQL Server
SELECT T1.* FROM (SELECT thinkphp.*, ROW_NUMBER() OVER ( ORDER BY rand()) AS ROW_NUMBER FROM (SELECT [NickName],[Gender],[Mobile],[RealName],[Birthday] FROM [SiteCustomerSupplement] [s] INNER JOIN [WxUser] [u] ON [u].[OpenId]=[s].[OpenId] WHERE [s].[OpenId] IN (SELECT T1.* FROM (SELECT thinkphp.*, ROW_NUMBER() OVER ( ORDER BY rand()) AS ROW_NUMBER FROM (SELECT DISTINCT [OpenId] FROM [WxPackagesOrder] WHERE [OrderStatus] >= 40 AND [RegionId] = 72) AS thinkphp) AS T1) AND [Birthday] BETWEEN '2021-10-26' AND '2021-11-02') AS thinkphp) AS T1
Obviously, it is much longer than the MySQL statement, mainly this paragraph
SELECT thinkphp.*, ROW_NUMBER() OVER ( ORDER BY rand()) AS ROW_NUMBER FROM
So when the problem comes, how to solve it?Just replace it with a native statement. Don’t use TP internal encapsulation.
Similar Posts:
- 12 Methods of SQL Error Injection [How to Inject]
- [Solved] MYSQL Error 1040 (HY000): too many connections
- [Solved] must appear in the GROUP BY clause or be used in an aggregate function
- MySQL error message: subquery returns more than 1 row and its solution
- How to solve Oracle ora-00937 Error: not a single group grouping function?
- Using join buffer (Block Nested Loop)
- [Solved] MYSQL Error: this authentication plugin is not supported
- How to Delete using INNER JOIN with SQL Server?
- MYSQL Incorrect usage of UNION and ORDER BY [How to Solve]
- [Solved] sql Error: You can’t specify target table ‘tb_cr_circulate_gtsc’ for update in FROM clause