mysql-error-1064

MYSQL stored function - create function (function definition) problem using FORMAT

Hi all, I keep receiving an error with the following code. I am trying to make a function that will format a field (content=0.0032) into a varchar/percent (content=0.32%). At the moment i'm just trying to get format to work, and it throws up an error "Error Code : 1064 You have an error in your SQL syntax; check the manual that corres...

Mysql Syntax Error

Any idea why this is popping 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 'CREATE TABLE `clocks` ( `id` int(11) NOT NULL AUTO_INCREMENT, ' at line 6 ** Here is the query ** CREATE TABLE `clients` ( `id` int(11) N...

Why is is giving me an SQL syntax error?

Do you have any idea why i get this: 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 '``, `title` varchar(255) collate latin1_general_ci NOT NULL default ``,' at line 3 The code is like this (the part im having problem with...) $sql = 'CREATE TABLE ...

Unable create a table - ERROR 1064 (42000): You have an error in your SQL syntax

I'm trying to execute this simple command: create table foo (clo int primary key unsigned auto_increment); But I get this error: ERROR 1064 (42000): 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 'unsigned auto_increment)' at line 2 ...

Problem in importing database in MySQL

I have a .sql file with some database backups inside. Now I want to restore them back to MySQL. How can I this using command line of MySqL please? I found this: mysql -u username -p -h localhost database_name < dumpfile.sql but I don't know what username should be, what database_name should be and how I could browse to a .sql file ...

Mysql syntax help

Query: select t1.col1 from table1 t1 inner join with (nolock) table2 t2 on t1.col2 = t2.col1 Am trying to use nolock option for optimized query in mySQL db, but for some reason the above query does not work and the error i receive is You have an error in your SQL syntax; Any thoughts? ...

How do you DELETE rows in a mysql table that have a field IN the results of another query?

here's what the statement looks like: DELETE FROM videoswatched vw2 WHERE vw2.userID IN ( SELECT vw.userID FROM videoswatched vw JOIN users u ON vw.userID=u.userID WHERE u.companyID = 1000 GROUP BY userID ) that looks decent to me, and th...

please help me construct this MYSQL Query (date / time)

I would like to construct a query that fetches results that occurred between NOW and 15 minutes ago, im getting a mysql error when I try the following , can you help me? thanks SELECT * WHERE user_id = '000' AND date_time < now( ) AND date_time > DATE_SUB( now( ) , INTERVAL 15 MINUTE) Error message: You have an error in yo...

Getting a 1064 Error in MySQL but query still completes? Not sure why!!

Hi there, I am trying to insert a lot of fields into a MySQL database, some are failing, so I am adding some code into my PHP script to try and track down what is occurring. The replace seems to work as I can see the fields being populated in mysql, but I get this error: 1064:You have an error in your SQL syntax; check the manual...

Having problem in sql query execution

Hi there, I have a problem in sql query execution.I am using this sql query: $userid = 1; $sql = mysql_query(" SELECT ID, Nm, Address, date_format(DateOfBirth, '%d%M%Y') as DateOfBirth FROM PersonalDetails where UserMasterID = $userid ") or die (mysql_error()); The result appears as: You have an error in your SQL syntax; che...

How to fix MySQL CREATE FUNCTION query?

I want to add mysql function: CREATE FUNCTION `chf_get_translation`(translation_id INT, site_lang INT) RETURNS text CHARSET utf8 BEGIN DECLARE translation TEXT; SELECT title INTO translation FROM chf_translations WHERE key_id = translation_id AND lang_id = site_lang; RETURN translation; END But get error...

Whats Wrong with this MySQL Script?

SELECT @cnt := COUNT(table_name) FROM information_schema.tables WHERE table_schema = 'TAA' and table_name = 'Clients'; IF (@cnt > 0) THEN INSERT INTO `ClientsBAK` SELECT * FROM `Clients`; END IF; I get a syntax error at IF(@cnt > 1) THEN error 1064 ...

mySQL: Select WHERE causes error - why?

Hi everybody, I have this query: SELECT `manufacturers`.*, `languages`.*, COUNT(`products`.`id`) AS productcount FROM (`manufacturers`) WHERE `manufacturers`.`flushed` = `0` JOIN `languages` ON `manufacturers`.`lang` = `languages`.`id` LEFT OUTER JOIN `products` ON `products`.`manuf` = `manufacturers`.`mid` GROUP BY manufacturers.i...

create procedure fails!?

Hi, when trying to create a simple procedure in mysql 5.1.47-community it fails everytime i've tried everything! even simple things like this! DELIMITER // CREATE PROCEDURE two () begin SELECT 1+1; end; // The error is ERROR: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server v...

insert ... select with divide operator in select errors?

Hi, the following query CREATE TABLE IF NOT EXISTS XY ( x INT NOT NULL , y FLOAT NULL , PRIMARY KEY(x) ) INSERT INTO XY (x,y) (select 1 as x ,(1/7) as y); errors with Error code 1064, SQL state 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use ne...

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Can someone please help as i've spent all day trying to fix this. I installed the latest XAMPP and now i can't connect to mysql from terminal.I checked my .profile file and the PATH seems ok. Does anyone know whats happened and what's the solution? PATH=$PATH:/Applications/XAMPP/xamppfiles/bin export PATH THIS IS A PROGRAMMING QUESTION...

MySQL temp table issue

Hi folks! I'm trying to use temp tables to speed up my MySQL 4.1.22-standard database and what seems like a simple operation is causing me all kinds of issues. My code is below.... CREATE TEMPORARY TABLE nonDerivativeTransaction_temp ( accession_number varchar(30), transactionDateValue date) ) TYPE=HEAP; INSERT INTO nonDerivativ...

Problems with mysql syntax

I´m trying to create a trigger on MySQL but I´m having a syntax problem, which I was not able to find. If someone more experience could help me it would be great (it´s the first time I use MySQL!)... The reason why I´m creating this trigger is for deleting all the orphan "labels", which has a many-to-many relation with "service_descript...

MySql Where-Subquery syntax error

This code worked in Sqlite which i have more experience with. I cant figure out whats wrong here. If it helps SELECT 1 FROM Post WHERE body = 'a'; doesnt give me a syntax error but this does select 1 WHERE NOT EXISTS (SELECT 1 FROM Post WHERE body = 'a' ) ; code: INSERT INTO `Post` ( `name`, ... `date`) select @0, ... @6 WHERE NOT ...

Inserting multiple rows with loop

Code: for($i = 1; $i <= $arr['var']; $i++) { if($i == $arr['var']): $insert .= '('.$n_id.', 12)'; else: $insert .= '('.$n_id.', 12),'; endif; } $uz = mysql_query("INSERT INTO `cars` (n_id, auto_id) VALUES '$insert'") or die(mysql_error()); Why it gives me a ...