Comparing two database variables at Server side script
Comparing two database variables at Server side script
shatrughan
Posts: 87Questions: 16Answers: 0
Hi, I'm stuck comparing two database variables using server php file as detailed below :
```Editor::inst( $db, 'Road_Movement' )->where( function ( $q ) use ( $Party_Code) {
$q->where( 'Party_Code', $Party_Code );
$q->where( 'Total_Amount','Final_Balance','=');
} )```
But, it does not give the expected result.
Please suggest how to tackle this issue.
Thanks & Regards
Shatrughan
This question has accepted answers - jump to:
Answers
What does it produce? And what is the expected result? Can you post the SQL that would produce the expected result?
Given the Total_Amount and Final_Balance be two column of database but upon comparison, nothing returns in json as reflected in attached snip.
Whereas there are such 35 records meeting the said condition. The following snap substantiate the same
The actual mysql query to produce the desired results is
SELECT * FROM `Road_Movement` where Party_Code='TC1100' AND Total_Amount=Final_Balance;
Please help to resolve the matter in question as to how we compare two database columns to filter the expected records.
Thanks
Shatrughan
Can you add
->debug(true)
just before the->process(...)
call please? Then shown me the JSON that the server is returning.Thanks,
Allan
Try this please
"Final_Balance" is not a variable that needs to be bound but it is a table column. Hence you would need to add "false".
https://editor.datatables.net/manual/php/conditions
Thanks.
Doh - thanks @rf1234! I missed that
Final_Balance
was a column, not a string!Allan