Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a table called "clientes" and another one called "phones", both of them have a column "_modificado" which have a timestamp, I use a function to get the last modified item to compare with my api and then update it.

how can I use the same function to retrieve the results of the 2 tables?

  function getLastSyncClientes(param) {
            db.transaction(
                function (tx) {
                    var sql = "SELECT MAX(_modificado) as lastS FROM clientes";

                    tx.executeSql(sql, [],
                        function (tx, results) {

                            var lastSync = results.rows.item(0).lastS;
                            param(lastSync);
                            log('Last local timestamp is ' + lastSync);

                        }
                    );

                },
                txErrorHandler,
                function () {

                }
            );
        }
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Compute the maximum for each table, then combine them:

SELECT MAX((SELECT MAX(_modification) FROM clientes),
           (SELECT MAX(_modification) FROM phones  )) AS lastS
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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