1
$\begingroup$

A pretty straightforward problem, you would think, but I cannot seem to find the answer in the documentation for SQLSelect.

The query I want to run is the following:

SELECT id, measurement, timestamp FROM myTable WHERE id IN (1, 2) ORDER BY timestamp

The Mathematica query I have so far is:

SQLSelect[dbConn,
    "myTable",
    {"id", "measurement", "timeStamp"},
    SQLMemberQ[{1, 2}, SQLColumn["id"]]
]

But I cannot seem to find an option to insert the ORDER BY requirement.

$\endgroup$
4
$\begingroup$

You can use "SortingColumns" in SQLSelect or simply use the SQL statement inside SQLExecute.

In the second case you simply write the SQL statement in the string:

SQLExecute[dbConn, "SELECT id, measurement, timestamp FROM myTable WHERE id IN (1, 2) ORDER BY timestamp"]

And you are returned triplets with {id, measurement, timestamp}.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.