This two-day project has a problem, limit use after the error.
The demand is like this, I have 3 tables, infor information table, mconfig material configuration table, maaply material request form, request to read out which person in the application form request which material
So I wrote this first:
Copy Code code as follows:
SELECT Infor.name,infor.phone,infor.add,
Mconfig.mname,mapply.acount,from_unixtime (mapply.atime, '%y-%m-%d ') as ' atime '
From mapply right JOIN infor to Mapply.uid = Infor.uid inner JOIN mconfig on mapply.mid = Mconfig.mid
WHERE Mapply.aid
In (
SELECT Aid
From ' mapply ' where state = $state
ORDER BY ' atime ', ' uid ' DESC
LIMIT 0,10
)
The result is an error.
At that time did not pay attention to the report of what error, just see limit what error, so changed the code
Copy Code code as follows:
SELECT Infor.name,infor.phone,infor.add,
Mconfig.mname,mapply.acount,from_unixtime (mapply.atime, '%y-%m-%d ') as ' atime '
From mapply right JOIN infor to Mapply.uid = Infor.uid inner JOIN mconfig on mapply.mid = Mconfig.mid
WHERE Mapply.aid
In (
SELECT Aid
From ' mapply ' where state = $state
ORDER BY ' atime ', ' uid ' DESC
)
<pre name= "code" class= "SQL" >limit 0,10</pre>
So no error, MO away thought OK, but after running found that the data have problems
and simply read out the content of the application form is not the same, only to find limit position misplaced, and then put limit in, the results of the following error
This version of the MySQL doesn ' t yet support ' LIMIT & in/all/any/some subquery '
Look carefully to know, in does not support limit. What about it?
So the Niang later learned that in the use of a temporary table, the need to find out the contents of the first,
The modified code is as follows:
Copy Code code as follows:
SELECT Infor.name,infor.phone,infor.add,
Mconfig.mname,mapply.acount,from_unixtime (mapply.atime, '%y-%m-%d ') as ' atime '
From mapply right JOIN infor to Mapply.uid = Infor.uid inner JOIN mconfig on mapply.mid = Mconfig.mid
WHERE Mapply.aid
In (
SELECT Aid
From (SELECT ' aid ' to ' mapply ' where state = $state
ORDER BY ' atime ', ' uid ' DESC
LIMIT 0,10) as ' TP '
)
After the operation, solve the problem ~ ~ ~