MySQL Forums
Forum List  »  Spanish

Re: Condicionar con variables @ en mysql
Posted by: Jaime Crespo
Date: July 17, 2014 06:57PM

Tu sintaxis es correcta:

mysql> SET @Var1:= (SELECT MAX(Colm1) FROM TablaA);
Query OK, 0 rows affected (0.02 sec)

mysql> SET @Var2:= (SELECT MAX(Colm1) FROM TablaB);
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT IF(@Var1 <= @Var2, @Var2, @Var1);
+----------------------------------+
| IF(@Var1 <= @Var2, @Var2, @Var1) |
+----------------------------------+
|                                5 |
+----------------------------------+
1 row in set (0.00 sec)

--
Jaime Crespo
http://dbahire.com

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Condicionar con variables @ en mysql
1553
July 17, 2014 06:57PM


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.