Database application - Sorting records

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Database application - Sorting records

Desfontaine François
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




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Database application - Sorting records

Werner-4
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. :)

[hidden email] 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: [hidden email]
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



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Loading...