Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
hvfalcao
Creator
Creator

Where Exists Renamed Field

Hi,

I'm trying to use where exists in some load script:

Pedido:

LOAD

IDPEDIDO,

IDPESSOA  // this IDPESSOA is the client ID.

IDREVENDEDOR; // this IDREVENDEDOR is the dealer ID.

SQL SELECT

IDPEDIDO,

IDPESSOA,

IDREVENDEDOR

FROM PEDIDO;

Revendedor:

LOAD

IDPESSOA AS IDREVENDEDOR,

NMPESSOA AS NMREVENDEDOR,

WHERE EXISTS (IDREVENDEDOR) 

// Here is the problem: If I choose "WHERE EXISTS (IDPESSOA)" it'll filter by IDPESSOA from table Pedido (that's not what I want, because it will load only the clients IDs. I need to filter all IDREVENDEDOR from table Pedido, witch will bring me only the dealers ID's.

SQL SELECT

IDPESSOA,

NMPESSOA

FROM PESSOA;

So... There is any way to apply Where Exists with renamed fields?

Thank You!

1 Solution

Accepted Solutions
sunny_talwar

Try this may be:

Pedido:

LOAD

IDPEDIDO,

IDPESSOA  // this IDPESSOA is the client ID.

IDREVENDEDOR; // this IDREVENDEDOR is the dealer ID.

SQL SELECT

IDPEDIDO,

IDPESSOA,

IDREVENDEDOR

FROM PEDIDO;

Revendedor:

LOAD

IDPESSOA AS IDREVENDEDOR,

NMPESSOA AS NMREVENDEDOR,

WHERE EXISTS (IDREVENDEDOR, IDPESSOA)

SQL SELECT

IDPESSOA,

NMPESSOA

FROM PESSOA;

View solution in original post

2 Replies
sunny_talwar

Try this may be:

Pedido:

LOAD

IDPEDIDO,

IDPESSOA  // this IDPESSOA is the client ID.

IDREVENDEDOR; // this IDREVENDEDOR is the dealer ID.

SQL SELECT

IDPEDIDO,

IDPESSOA,

IDREVENDEDOR

FROM PEDIDO;

Revendedor:

LOAD

IDPESSOA AS IDREVENDEDOR,

NMPESSOA AS NMREVENDEDOR,

WHERE EXISTS (IDREVENDEDOR, IDPESSOA)

SQL SELECT

IDPESSOA,

NMPESSOA

FROM PESSOA;

hvfalcao
Creator
Creator
Author

Sunny,

It works! Thank you!