MySQL Forums
Forum List  »  Perl

Is it possible to use several statements in one query?
Posted by: Zuko Zukoff
Date: June 13, 2006 04:08PM

for example

$h->execute('100');

query:
SET @id = ?;
UPDATE Table SET
T2 = SELECT smth FROM Table2 WHERE TableID=@id,
T3 = SELECT smth FROM Table3 WHERE TableID=@id,
T4 = SELECT smth FROM Table4 WHERE TableID=@id,
T5 = SELECT smth FROM Table5 WHERE TableID=@id
WHERE ID=@id

But... i done it that way... i have to send six copies of data... because perl's mysql driver does not allow several statements. I've tryed it with PHP or mysql console. I can do whatever i want!

$h->execute('100','100','100','100','100','100');

query:
UPDATE Table SET
T2 = SELECT smth FROM Table2 WHERE TableID=?,
T3 = SELECT smth FROM Table3 WHERE TableID=?,
T4 = SELECT smth FROM Table4 WHERE TableID=?,
T5 = SELECT smth FROM Table5 WHERE TableID=?
WHERE ID=?

Or for example i want to get today date, compare it with date retrieved from some table and then update.




Edited 2 time(s). Last edit at 06/13/2006 04:12PM by Zuko Zukoff.

Options: ReplyQuote


Subject
Written By
Posted
Is it possible to use several statements in one query?
June 13, 2006 04:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.