-2

I'm new to mysql and I don't understand the purpose of the @ in the following code, if someone could explain to me the next piece of code:

DROP PROCEDURE IF EXISTS  INREGISTRARE_CLIENT;
DELIMITER //

CREATE PROCEDURE INREGISTRARE_CLIENT(_nume char(20), _prenume char(20), _adresa_id int, _sex int)

BEGIN
   SET @is_adresa_id = NULL;
   SELECT @is_adresa_id := id FROM adresa;
   IF (@is_adresa_id IS NOT NULL) THEN
    INSERT INTO client_card_fidelitate (nume, prenume, adresa_id, sex, data_inregistrare) VALUES
                   (_nume, _prenume, _adresa_id, _sex, CURRENT_DATE());
   END IF;
END //
IDELIMITER ;
sixfeet
  • 934
  • 4
  • 16
  • 33
  • [User-Defined Variables](http://dev.mysql.com/doc/refman/5.7/en/user-variables.html). – raina77ow Nov 23 '14 at 14:30
  • Check the manual: http://dev.mysql.com/doc/refman/5.5/en/set-statement.html –  Nov 23 '14 at 14:30
  • They are user-defined variables. Check this [link](http://stackoverflow.com/questions/1009954/mysql-variable-vs-variable-whats-the-difference) – Academia Nov 23 '14 at 14:33
  • I don't understand why is my question downvoted...what I did wrong? – sixfeet Nov 23 '14 at 14:35

1 Answers1

0

it's the syntax to use variable in MySQL. For example: SET @a = 1;//this means the @a variable is set to value 1.

Kenny Tai Huynh
  • 1,464
  • 2
  • 11
  • 23