RevQueryDatabase help

Bill bill at bluewatermaritime.com
Fri Mar 18 22:28:42 EST 2005


I finally figured out why the SELECT LAST_INSERT_ID() sql statement wasn't
working.

I was using:
revQueryDatabase(tConnection, dbQuery)

Which doesn't give you data from the query but instead results in a useless
number that increments weirdly (useless to me anyway).

Instead all I had to do wos use:

revDataFromQuery(,,tConnection, dbQuery)

As shown below and it now works

put empty into fld "Exec result"
  put revConnectionOfQuery("ConnectCrew") into tConnection
  -- first escape error
  if tConnection is not a number then
    put "tConnection is:" && dbCUR into fld "Exec result"
    exit mouseUp
  end if
 limit 1" into dbQuery
put "SELECT LAST_INSERT_ID()" into dbQuery
put revDataFromQuery(,,tConnection, dbQuery) into LastInsertID


Also I found out that the "SELECT LAST_INSERT_ID() FROM tablename" sql
statement results in a repeat of the ID for the number of rows in the table
(don't get that either).

Now everyone on this list knows that I program by trial and error...


On 3/18/05 2:44 PM, "mfstuart at cox.net" <mfstuart at cox.net> wrote:

> Bill,
> 
> If you want to get the last ID from a table in MySQL, use the following SELECT
> statement, and put the result into a variable - which will be the last ID
> value in that table:
> 
> SELECT id FROM tripulatnes ORDER BY id DESC limit 1
> 
> This selects the column: id from the table: tripulantes, and sorts the table
> by column: id, in descending order. This returns the last record in the table.
> Warning: this only returns the last record, not the greatest (or MAX) value in
> that column, which I'm assuming is the Primary Key to the table.
> 
> Now if you want the MAX value returned from the column: id, use the following
> SELECT statement:
> 
> SELECT MAX(id) FROM tripulantes
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> 

            |    |    |
           )_)  )_)  )_)
          )___))___))___)\
         )____)____)_____)\\
       _____|____|____|____\\\__
-------\                   /--------- http://www.bluewatermaritime.com
 ^^^^^ ^^^^^^^^^^^^^^^^^^^^^
  ^^^^      ^^^^     ^^^    ^^
       ^^^^      ^^^

24 hour cell: (787) 378-6190
fax: (787) 809-8426

Blue Water Maritime
P.O. Box 91
Puerto Real, PR 00740





More information about the use-livecode mailing list