#1 2010-10-02 12:53:50

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Complex SQL request

I have understand how retrive data from a table but now I must retrive data with a complex SQL from many tables:

SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons
LEFT JOIN Orders
ON Persons.P_Id=Orders.P_Id
ORDER BY Persons.LastName

Can you explane how can I do it?

Offline

#2 2010-10-03 08:57:31

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,654
Website

Re: Complex SQL request

You can use this overridden method of any TSQLRestClient client:

...
    /// Execute directly a SQL statement, expecting a list of resutls
    // - return a result table on success, nil on failure
    function ExecuteList(const Tables: array of TClass; const SQL: RawUTF8): TSQLTableJSON; virtual; abstract;

Use [TSQLPersons,TSQLOrders] in the Tables parameters (for the internal caching mechanism, but it's not mandatory).
Post your SQL request in the SQL parameter.
It will return a TSQLTableJSON instance to you, in which you'll have all the resulting rows.

Offline

Board footer

Powered by FluxBB