MySQL LOAD DATA Syntax
Using LOAD DATA LOCAL INFILE is a much faster way to insert lots of data into a table than using INSERT. The only preliminary step is to format the input file with unique field separators.
In most cases MySQL by default will not allow LOAD DATA LOCAL operations. This feature needs to be enabled during MySQL source code compilation, mysqld daemon startup, or mysql CLI startup. Start mysql CLI like so:
mysql --local-infile=1 -u -p
In the following example, “list2” is a file containing one entry per line. The “biglist” table has three comma-separated columns: word_id (autoincrement), word1 , and word2 .
LOAD DATA LOCAL INFILE '/wordlists/incoming/list2' INTO TABLE biglist FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' (word1, word2);
Not very complicated. You can do the same from inside a shell script:
#!/bin/ksh INFILE=/wordlists/incoming/list2 mysql --local-infile=1 -u -p << EOF LOAD DATA LOCAL INFILE '$INFILE' INTO TABLE biglist FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' (word1, word2); EOF
I have a MySQL Database running on a Linux server with a Users Table, I need to export the information in that table so I can use it on a different MSSQL Server that is running a similar Users table, I would like to create a PHP script that with the press of a button (or on load) prompts me to download the .sql file which contains the information in the Users table. I really don’t know where to start, any help is appreciated.
I was trying to visit the website http://www.l4dmaps.com. Unfortunately, each time visit that website, this error shows up:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘where `selected`=1 LIMIT 1’ at line 1
What’s the problem with that?
Was it the website’s problem or my computer’s?
What’s the best solution/s for it?
tnx!
Hey.. so basically I am trying to get my product listing page to open on a page when I click a product. The code for that is shown below….
$data = mysql_query(“SELECT * FROM products;”) or die(mysql_error());
while($info = mysql_fetch_array( $data ))
echo ‘“‘;
At the moment that part is working as its setting the ID in the url to whatever the ID of the product is. Now the problem is that it won’t load the CSS for this. Because for when I change pages switch cases have been used. Now because the ID is constantly changing, I have no idea how to sort this other than put variables in the switch case. The switch case is as shown below.
@mysql_select_db($database) or die( “Unable to select database”);
$data = mysql_query(“SELECT * FROM products;”) or die(mysql_error);
while($info = mysql_fetch_array( $data ));
if(isset($_GET[‘page’]))
{
switch ($info) {
case ‘products.php?uid=[ID]>’:
include(‘products.php’);
break;
}
}
The switch case is located in the Index.php (which has also been used for the css) where as the products listing is in a different file. Where the coding I just showed for the switch does not work :(.
Any help is greatly appreciated, cheers.