[Gambas-user] Database application - Sorting records
Werner
werda at ...1000...
Mon Oct 10 05:00:16 CEST 2005
Desfontaine François wrote:
>I am testing the possibility to use Gambas to make Mysql database
>projects. I have found how to add, modify, delete or display records
>from a MySql table, but I have not found how to sort records.
>(I have found no possibility for executing a SQL command "SELECT * FROM
>table ORDER BY field")
>Have somebody a response to that question ?
>Thanks.
>
>Francois
>
>
>
Assuming
- hConn is a properly opened connection and
- res is a result object
try the following:
res = hConn.Find("people","lastname=&1 AND firstname=&2 ORDER BY
birthdate DESC LIMIT 10","Doe","John")
It should give you up to 10 people named John Doe sorted descending by
birth date.
Also of interest to you might be how to use the mysql library functions
such as MIN, MAX, AVG, SOUNDEX etc. There was a recent discussion on
this under the title "Exotic Mysql Problem". I quote it below. Actually
it's a good example why top posting is a bad idea :-)
Regards
Werner
------------------------------------------------
Thanks, this worked perfectly.
However, i dont know whether this is a bug or a feature. Maybe we have
to ask MS to solve this mystery. :)
nigel at ...38... schrieb:
Alex,
Not sure how you are using this but I have successfully tested the
following:
rResult = hConn.Exec("Select max(field) as maxfield from table")
.
.
.
PRINT rResult!maxfield
Does this help?
Nigel
Message Received: Sep 29 2005, 08:27 PM
From: "Alex Ciric" To: gambas-user at lists.sourceforge.net
Cc: Subject: [Gambas-user] Exotic Mysql Problem
Hi.
In my application i have to use the mysql-macro max().
If i do a query like "select * from table" this works very good with
gambas and i am able to use the results for further stuff.
But if i do a query like "select max(field) from table" i get an error
message "field not found in myqsl table"
Does anyone know this behavior or have a workaround?
Sincerely
alex Ciric
More information about the User
mailing list