Sorry, I'm a bit 'green' in this part. Maybe one of you can help me.
I want to make a combination of 2 tables and from both tables of them I want a few fields. Like
SELECT o.pickup_date, t.order_number FROM transport_order o INNER JOIN transport t ON o.transport_id = t.transport_id WHERE o.pickup_date ..etc.
I figured this out:
- Code: Select all
/** @type {QBSelect<db:/test_db/transport_order>} */
var query = databaseManager.createSelect('db:/test_db/transport_order');
query.where.add(query.columns.pickup_date.between(pickUpDate_from,pickUpDate_to));
/** @type {QBJoin<db:/test_db/transport>} */
var transportJN = query.joins.add("db:/test_db/transport", JSRelation.INNER_JOIN);
transportJN.on.add(query.columns.transport_id.eq(transportJN.columns.transport_id));
query.result.add(transportJN.columns.order_number);
var testFS = databaseManager.getFoundSet(query);
application.output(testFS.getRecord(1).order_number);
For a reason or the other, I don't get the expected result (null)
I try this also without the relation, like:
- Code: Select all
query.result.add(query.columns.pickup_date,"test");
but this also didn't get the column "test" in the foundset.
What I'm doing wrong?
Thanks in advance!