« MySQL/Variables utilisateurs » : différence entre les versions

Contenu supprimé Contenu ajouté
Aucun résumé des modifications
Ligne 3 :
La possibilité de définir des variables dans une requête est assurée par l'opérateur d'assignation <code>:=</code>.
 
Par exemple, soit <code>@total</code> une variable servant à calculer un total, younécessaire havepour toen havedéduire the total column first because it must be calculated before the individual percentage calculationsles pourcentages.
* SessionLes variables arede setsession fordurent thele durationtemps of thedu thread.
* Une variable définie dans la liste de champ ne peut pas être utilisée comme une condition.
* In the vast majority of cases you'd use a programming language to do this sort of thing.
* La valeur d'une variable est définie avec <code>SET</code> ou bien SELECT accompagné de :=.
* Mysql variables can be useful when working on the Mysql command line.
* If no records are returned, the user variable will not be set for that statement.
* A user variable set in the field list cannot be used as a condition.
* The value of a variable is set with the SET statement or in a SELECT statement with :=
 
<source lang=sql>
Ligne 15 ⟶ 12 :
select @test + 1
 
set @startdate='some_start_datedate_debut', @enddate='some_end_datedate_fin'
 
SELECT @toremember:=count(*) FROM membros;