I have a table transaction_details
cta scta sscta charge
102 1 1 80.00
102 1 1 5.00
102 1 2 20.00
102 1 2 2.00
105 1 0 30.00
105 2 0 50.00
107 1 0 45.00
107 1 0 71.00
For example, I want to make a query from account 102 1 2 to account 105 1 0
I have only achieved the following:
$transaction_details = TransactionDetails::whereBetween('cta', [ 102, 105 ])->get();
I want to make a query from account cta(102) scta(1) sscta(2) to account cta(105) scta(2) sscta(0):
cta scta sscta charge
102 1 2 20.00
102 1 2 2.00
105 1 0 30.00
105 2 0 50.00
2
Answers
The requirements are not very clear; for example, if there you have this:
Do you want to select rows 4, 5, 6, 7?
A "raw" approach
If the answer is YES, you could concatenate the columns.
This supports values up to 999 for the cta, scta and sscta columns.
A clearer and more fluent approach.
Equivalent query:
I can’t find a simple solution without raw where.
This should work: