Halaman

Jumat, 05 September 2014

[MySQL] Using temporary variables on select statements

When your query need a long formula, to make it "maintainable" and "readable" you sometime need  the help of a temporary variable, simply put: you assign them on the select term by using the syntax:

@tempName := price * discount_percent as disc, @tempName2 := @tempName + price as net_price

And that should be it folks! ;)