2 queries in one stored procedure

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

2 queries in one stored procedure

Post by ddragas »

one more question

how can 2 or more queries be executed in one stored procedure.
This example works, but returns results only from first query

Code: Select all

 
BEGIN
DECLARE lastPayment DOUBLE ;
 
select payments.payment
from payments 
where client =  clijentSearch
order by id desc limit 1;
 
set lastPayment = payment;
 
select (lastPayment - (sum(table1.quantity * table1.price))) as cashBalance 
    from table1
    where table1.client = clijentSearch; 
 
END
 
Post Reply