The @ sign is a variable in SQL.
In MySQL, it is used to store values ββbetween successive runs of a query or to transfer data between two different queries.
Example
Data transfer between two requests
SELECT @biggest:= MAX(field1) FROM atable; SELECT * FROM bigger_table WHERE field1 > @biggest;
Another use relates to ranking, in which MySQL does not have built-in support.
Save value for sequential query runs
INSERT INTO table2 SELECT @rank := @rank + 1, table1.* FROM table1 JOIN( SELECT @rank := 0 ) AS init ORDER BY number_of_users DESC
Please note that for this to work, the order in which the lines are processed in the request must be fixed, it is easy to get it wrong.
Cm:
http://dev.mysql.com/doc/refman/5.0/en/user-variables.html
mysql sort order definition
http://www.xaprb.com/blog/2006/12/15/advanced-mysql-user-variable-techniques/
UPDATE
This code will never work.
You have just opened a connection before and do not install @fields anywhere.
Therefore, they currently contain null values.
Upstairs you cannot use @vars to denote field names , you can only use @vars values ββfor values.
$sql1 = " LOAD DATA LOCAL INFILE 'import.csv' REPLACE INTO TABLE tablename FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\"' IGNORE 1 LINES (`normalField`, @field1, @field2, `normalField2`, @field3, @field4)";
Johan
source share