how to compare the value of current resultset with previous one?
Please have a look at the code snippet
while ($rslt = fetch_array($result))
{
//$row++;
if (bccomp ($row, $row_limit, 0) != 1)
{
/*HEADER*/
if ($row == 0)
{
foreach ($_SESSION['market']['data'] as $title => $field)
{
//Output Header Cell
//$title++;
$worksheet->write ($row, $col, title,$formatHeader);
//Advance Column
$col++;
}
}
//Reset Column Position
$col = 0;
//Advance Row
$row++;
}
/*BODY*/
foreach ($_SESSION['market']['data'] as $title => $field)
{
//Output Body Cell
$worksheet->write ($row, $col, $rslt[$field], $formatNormal);
//Advance Column
$col++;
}
//Reset Column Position
$col = 0;
//Advance Row
$row++;
}
}
its working completly fine and i am happy with it.but now the requirement is: in each row's 0th开发者_JAVA技巧 column there is a name,and with respect to that name there are other fields,now what i want to do is to compare each row's 0th column,problem is how to store previous row's 0th column.than logic is like ($rslt['name']===$rslt[//previous column name]). Please sort me out .
You cannot use the state
alias. You have to repeat your IFNULL()
expression:
... CONCAT(a, aa, IFNULL((SELECT p.name FROM p WHERE p.id = x.name), 'N.A.'))
In addition, I believe you mean CONCAT()
instead of CONCATE()
. Also note that N.A.
should be wrapped in single quotes: 'N.A.'
.
Test case:
SELECT CONCAT('1-', '2-', IFNULL((SELECT NULL), 'N.A.'));
+---------------------------------------------------+
| CONCAT('1-', '2-', IFNULL((SELECT NULL), 'N.A.')) |
+---------------------------------------------------+
| 1-2-N.A. |
+---------------------------------------------------+
1 row in set (0.00 sec)
SELECT CONCAT('1-', '2-', IFNULL((SELECT 3), 'N.A.'));
+------------------------------------------------+
| CONCAT('1-', '2-', IFNULL((SELECT 3), 'N.A.')) |
+------------------------------------------------+
| 1-2-3 |
+------------------------------------------------+
1 row in set (0.00 sec)
精彩评论