Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Two queries
Fri, Jun 6 2008 11:10 AMPermanent Link

John
Hi.

Is it possible just with SQL to use the result of one query in another query?

For instance:
SELECT MAX(No) FROM Customers;
SELECT * FROM SALESLINES WHERE CUSTNO={Result from first query};
Fri, Jun 6 2008 11:46 AMPermanent Link

"Robert"

"John" <eydunl@post.olivant.fo> wrote in message
news:0E5DDB2F-72D5-4905-AF6D-513F36D1ED28@news.elevatesoft.com...
> Hi.
>
> Is it possible just with SQL to use the result of one query in another
> query?
>
> For instance:
> SELECT MAX(No) FROM Customers;
> SELECT * FROM SALESLINES WHERE CUSTNO={Result from first query};
>

select * from salesline where custno in
(select max(no) from customers)

Be careful though, there are speed issues with these type subqueries. A
safer way is using a script

select max(no) maxno into memory\temp from customers;
select * from salesline
join memory\temp on maxno = custno;

Robert

Fri, Jun 6 2008 2:26 PMPermanent Link

John


Thanks Smile
Image