mysql-error-1064

IF construct in MySql producing error #1064

I am attempting to run the following code in phpMyAdmin: set @tagTokenNum=0; select @tagTokenNum:=tag_token_id from tag_token where tag_token_name = 'XXX'; delimiter go if @tagTokenNum is null then insert into tag_token (tag_token_name) values ('XXX'); select @tagTokenNum:=last_insert_id(); end if; go I have also tried this wit...

Simple MySQL INSERT error...

No doubt I'm missing something really simple here but I just can't see the problem with this query which is producing the following error: SQL query: INSERT INTO ads( ad_id, author, ad_date, category, title, description, condition, price, fullname, telephone, email, status, photo, photothumb ) VALUES ( NULL , 'justal', ...

Problem importing mysql procedures generated from mysqldump --routines

I use the mysqldump tool to make copies of my database. The problem is, when I use the --routines parameter to output my stored procedures along with my data, the generated output causes an error when I try to import it. It goes something like this: % mysqldump --routines MyDB | mysql MyDB2 (where MyDB2 already exists but is empty) ...

MySQL INSERT INTO ... SELECT throws Error 1064

Trying to duplicate some rows in a table but just change the ssreportid column from 4 to 6: INSERT INTO ssreportparticipant (ssreportid, sssurveyparticipantid) VALUES SELECT 6, sssurveyparticipantid FROM ssreportparticipant WHERE ssreportid = 4 The error says #1064 near 'select 6, ...' but if I just run the select clause, it selects...

Error in mysql while importing from csv

This is my command line query. mysql> load data local infile "c:\\re\\30-11-08.csv" into table powerdata(Date, DG1, DG2, DG3, Dg4, DG5, ChillerPanel1, ChillerPanel2, ChillerPanel3, ChillerPanel4,1st_Floor, 2nd_Floor, 3rd_Floor, 4th_Floor, UPS1, UPS2, UPS3, UPS4, UPS5,Server_Power, Cooling_Power) fields terminated by...

MySql Stored procedure creation Error

I am trying to create a stored procedure in my mysql database usin the below code.I am getting an error.Please help me to solve My MySQl version is 5.0.51b CREATE PROCEDURE tv_insert_user(IN firstName VARCHAR(25), IN lastName VARCHAR(25), IN emailId VARCHAR(22),IN countryId INT,IN stateId INT) BEGIN INSERT INTO tv_user_master(FI...

PHP/MySQL Update code

I'm trying to call a row update from php to an mysql database. It fails out but when i try to call an insert new row formated just the same it works. $result = mysql_query("INSERT INTO auth (username, password, studycode, description, server) VALUES ('$username', '$password', '$studycode', '$description', '$server')"); but this code f...

Why does this SQL INSERT statement return a syntax error?

Ok I have a very simple mysql database but when i try to run this query via mysql-admin i get weird errors INSERT INTO customreports (study, type, mode, select, description) VALUES ('1', '2', '3', '4', '5'); Error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for t...

Error creating MySQL table

Hi, I get an error when running the following create table: CREATE TABLE Event ( id VARCHAR(10) NOT NULL, title VARCHAR(100), start_date DATE NOT NULL, end_date DATE, description TEXT, url VARCHAR(200), website VARCHAR(200), location VARCHAR(32) NOT NULL; PRIMARY KEY (id), FOREIGN ...

How to restore mysql database

Hi All, I have taken the backup of mysql database but when I am trying to restore it my stored procedures are not getting restored. Is there any way like for backup we use --routines in mysqldump command. Can we do any such thing in mysql. If I am using mysqldump then it is just dumping mysql tables but if I am using mysql command to ...

Why doesn't my MySQL query work?

Why doesn't my MySQL query work? Query: DELETE FROM jos_community_awards a LEFT JOIN jos_community_users u ON a.userId = u.userid WHERE a.points > u.points; 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 'a LEF...

What's wrong with this mysql query?

SELECT app_contracts.*, app_customers.id as customer, app_boards.id as board WHERE app_customers.id=app_contracts.customer_id AND app_boards.id=app_contracts.board_id ORDER BY app_contracts.id DESC Error: Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server ve...

mysql limit inside group?

I want to limit the size of records inside a group, and here is my trial, how to do it right? mysql> select * from accounts limit 5 group by type; 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 error in mysql

I am trying to create a stored procedure in MYSQL. Below is my code which is giving syntax error. Can anyone please help me. CREATE PROCEDURE productpricing ( OUT pl DECIMAL(8,2), OUT ph DECIMAL(8,2), OUT pa DECIMAL(8,2) ) BEGIN SELECT Min(prod_price) INTO pl FROM products; SELECT Max(prod_price...

Python error: int argument required

What am I doing wrong here? i = 0 cursor.execute("insert into core_room (order) values (%i)", (int(i)) Error: int argument required The database field is an int(11), but I think the %i is generating the error. Update: Here's a more thorough example: time = datetime.datetime.now() floor = 0 i = 0 try: booster_cursor.exe...

mysql delimiter error

Modifed. DROP FUNCTION IF EXISTS PersonName; DELIMITER |; CREATE FUNCTION PersonName( personID SMALLINT ) RETURNS CHAR(20) BEGIN DECLARE pname CHAR(20) DEFAULT ''; SELECT name INTO pname FROM family WHERE ID=personID; RETURN pname; END; | DELIMITER ; whats wrong with this code? i get following error with it. There seem...

Mysql create table query problems?

I want to create a table, which name something like : name_thisyear_thisweekofyear, e.g -> name_2009_40 I tried this query: CREATE TABLE IF NOT EXISTS name_YEAR(NOW())_WEEKOFYEAR(NOW())(id int NOT NULL AUTO_INCREMENT PRIMARY KEY, phone_no int, created datetime, deleted datetime) It doesnt work. Please help Error Message: #1064 - Y...

can anyone smarter than me see why this script from mysql workbench is broken giving ERROR 1064 (42000) ?

Can anyone see what I am missing? the section of my script below fails with the following message: ERROR 1064 (42000) at line 26: 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 ') , PRIMARY KEY (id), INDEX fk_gaprodsku_gatransid (transactionid...

MySQL error 1064, not sure what I'm doing wrong here...

mysql -u username -p database -e deletedata.sql I get ERROR 1064 (42000) at line 1: 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 'deletedata.sql' at line 1 DELETE FROM 'table1' WHERE 'column' <= date_sub(current_date, INTERVAL 37 day); DELETE FROM...

can anybody suggest the Alternate of "intersect" & "Minus" for MYSQL?

GOT error for the following query in MYSQL(version5.1) SELECT year,month,sum(fact_1),sum(fact_2),sum(fact_3),sum(fact_4) from( select year,month,fact_1,fact_2,0 as fact_3,0 as fact_4 from table_1 intersect select year,month,0 as fact_1,0 as fact_2,fact_3,fact_4 from table_2 ) as combined_table group by month,year Error Line with code#...