PHP MySQL database to find the most recent fields of the same content, with their ID subtraction output difference
Table MYDB1, fields: (ID, number of periods, number 1, number 2, number 3), each issue has three numbers (such as 356). 3 of these are (number 1 field), 5 is (number 2 field), 6 is (number 3 field). Wait until the N-period lottery number appears again 356, use this 356 ID minus the previous 356 ID output difference.
$array = Array ();
while ($row = Mysql_fetch_assoc ($result)) {
if (In_array ($row [' content '], $array)) {
$a = $row [' id '];
foreach ($array as $key = = $content) {
if ($row [' content ']== $content) {
$b = $key;}}} else{
$array [$row [' id ']] = $row [' content '];}}
Please write a detailed written, Thank you PHP MySQL
Share to:
------Solution--------------------
Select (t2.id-t1.id) from table1 t1,table2 T2 where t1.num1=t2.num1 and t1.num2=t2.num2 and T1.NUM3=T2.NUM3
------Solution--------------------
SELECT a.ID, a.id-b.id as Sub
From MYDB1 A, mydb1 b
WHERE A. Number 1 = B. Number 1
and a. Number 2 = B. Number 2
and a. Number 3 = B. Number 3
Having sub >0