[Gambas-user] HOW TO MOVE IN DATASOURCE

Fabien Bodard gambas.fr at ...626...
Sun Jan 20 11:41:15 CET 2008


Le Saturday 19 January 2008 23:44:34 Benoit Minisini, vous avez écrit :
> On samedi 19 janvier 2008, Nx GT-R BOY wrote:
> >  Hi, hope somebody help me with this one, is there a way to move the
> > datasource row, to a given record, but not just by index, I mean:
> >
> > I can do in MySQL console something like this:
> > select code from colors where person = "someone"
> >
> > so, I can do:
> > resultado = conexion.Exec (select code from colors where person =
> > "someone")
> >
> > Then
> > resultado!code will have the record I am looking for, but how do I move
> > my datasource to that record to show it at screen, I know I can do:
> >
> > DataSource1.MoveTo(X)
> >
> > But that its going to work only when "code" is numeric, what about if
> > code es "RD" (for RED color), so, how do I move?, Must I add a numeric
> > field in all my tables to be able to do what I want?
>
> MoveTo(X) moves to the Xth record of the underlying Result object of the
> DataSource. It is not related at all with a possible numeric key.
>
> But I don't know if it is possible in SQL to find the order of a specific
> query inside another query. It's beyond my sql skills... If anybody have an
> idea?
>

moveto... move like in an array...

in fact it is not the Field (code) value that is used


so never problem to walk throuth the result.

You can have an ordered result by using ORDER BY ... and ... DESC keys


For Benoit,

There is in fact 2 possiblity you can look at :

- Sub Request (IN operator)
- INTERSECT


SELECT DESCRIPTION
FROM ARTICLES 
WHERE NUMERO_ARTICLE IN
(SELECT NUMERO_ARTICLE
FROM LIGNE_COMMANDES
WHERE NUMERO_COMMANDE= '12491');

'sous requête... heu nan ça doit as être bon




SELECT NUMERO_CLIENT, NOM, PRENOM
FROM CLIENTS
WHERE NUM_REPRESENTANT='12'
INTERSECT
SELECT CLIENTS.NUMERO_CLIENT, NOM, PRENOM
FROM CLIENTS, COMMANDES
WHERE CLIENTS.NUMERO_CLIENT = COMMANDES.NUMERO_CLIENTS;

affiche le numéro de client, nom, le prenom de tout les client du representant 
n°12





> Otherwise, you have to do the search yourself, one record by one record.
> Really stupid, but if there is no other solution...
>
> Regards,






More information about the User mailing list