MySQL Forums
Forum List  »  Newbie

Conditionals
Posted by: Michael Smith
Date: March 13, 2023 12:59AM

I am trying to write code to deal with a conditional in MySQL.

I have the latest free Invoice Number stored in a table "Storage01" in field "Nextra5". There is only 1 row in the table.

I want to see if the new file being built in the "Invoices01" table already has an Invoice Number. If it doesn't contain any invoice numbers then I would populate the column "invnbr" with @mnewnumber.

I cannot get to first base with this. The most promising version is below but this unfortunately only generates error messages.

SELECT @mnewnumber := Nextra5 from Storage01 ;

SELECT count(ITEM) FROM Invoices01 as V1 where invnbr > 0;

IF V1 = 0 THEN
update Invoices01 set invnbr = @mnewnumber;
ENDIF;


Mike

Options: ReplyQuote


Subject
Written By
Posted
Conditionals
March 13, 2023 12:59AM
March 14, 2023 12:09AM


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.