+——–+ To set a variable explicitly to a
+——–+ To set a variable explicitly to a particular value, use a SET statement. SET syntax uses = rather than := to assign the value: mysql> SET @sum = 4 + 7; mysql> SELECT @sum; +——+ | @sum | +——+ | 11 | +——+ A given variable’s value persists until you assign it another value or until the end of your mysql session, whichever comes first. Variable names are case sensitive: mysql> SET @x = 1; SELECT @x, @X; +——+——+ | @x | @X | +——+——+ | 1 | NULL | +——+——+ SQL variables can be used only where expressions are allowed, not where constants or literal identifiers must be provided. Although it’s tempting to attempt to use variables for such things as table names, it doesn’t work. For example, you might try to generate a temporary table name using a variable as follows, but the result is only an error message: mysql> SET @tbl_name = CONCAT(’tbl_’,FLOOR(RAND( )*1000000)); mysql> CREATE TABLE @tbl_name (int_col INT); ERROR 1064 at line 2: You have an error in your SQL syntax near ‘@tbl_name (int_col INT)’ at line 1 SQL variables are a MySQL-specific extension, so they will not work with other database engines. 1.16 Telling mysql to Read Queries from a File 1.16.1 Problem You want mysql to read queries stored in a file so you don’t have to enter them manually. 1.16.2 Solution Redirect mysql’s input or use the SOURCE command. 1.16.3 Discussion
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services