Error 1064 (42000) in Mariadb mysql - mysql

The error is this one
ERROR 1064 (42000) at line 41: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
and below is the line 41
INSERT INTO `users` (`user_id`,`first_name`,`last_name`,`status_input`);
I'm running it at mariadb mysql for linux (centOS)

The correct syntax would be
INSERT INTO `users` (`first_name`,`last_name`,`status_input`) VALUES ('John', 'Doe', 'Talk to me...');
MariaDB expects values to be set when inserting something, since otherwise there would be nothing to insert. Also, I've omitted the user_id, since this is an AUTO_INCREMENT PRIMARY KEY column and will be set automatically. You should not set this to a value manually, unless there is a good reason.

Related

I am not able to create a table in MySQL from Ubuntu os

mysql> create table prasad1(empid number(1),name varchar(4));
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 'number(1),name varchar(4))' at line 1
This is the correct query create table prasad1(empid int(1),name varchar(4));
Explanation: There is not number field type in MySQL. You can use either int or integer.

What is the error in this INSERT SQL query?

Where is the error in this query?
INSERT INTO chat (`id`,`user`,`message`,`date`)
VALUES (null,'user','test',CURRENT_TIMESTAMP);
This is the error message I receive:
"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 ''id','user','message','date') VALUES (null,'user','test',CURRENT_TIMESTAMP)' at line 1"
if the id is autoincrement then use this instead
INSERT INTO `chat` (`user`,`message`,`date`)
VALUES ('user','test',NOW());
Its difference between single quote ' and backtick `

Mysql syntax error : 'WHERE NOT LIKE'

I'm trying to track the page views by inserting only unique values every 24h.But when I run this query I get a syntax error.
insert ignore into profilepageviews values( '77.777.777.777' , CURRENT_TIMESTAMP, '5') where hitdate NOT LIKE '%2012-06-26%'
Error:
#1064 - 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 hitdate NOT LIKE '%2012-06-26%'' at line 1
You can not use WHERE clause with INSERT, You might want UPDATE

MySQL insert record

I have this SQL query:
insert into messages
(message, hash, date_add)
values
('message', 'hash', NOW())
ON DUPLICATE KEY IGNORE
hash is unique, what is wrong with query? i got the error:
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 'IGNORE' at line 1
According to MySQL doc the syntax should be :
INSERT IGNORE INTO messages (message, hash, date_add)
VALUES('message', 'hash', NOW());

Mysql insert command syntax

I am using MYSQL 5.1, I am trying to write an insert statement in my java class. It sounds very simple but i tried and getting exception. I am sure there is a syntax error with my code. below is the snippet could any one help me out here.
ID is in primary key
atm_ID is varchar
trasn_id is varchar
sysDate is Date
rest is int
Please help me out.
Error:
SQL statement is not executed!com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 '£10, £20, £50, £100, trans_Id) VALUES (7,'hello','hello','2','2','2','2','2','he' at line 1`
Code:
String query = "INSERT INTO atm_data (ID,atm_Id, sysDate, availBalance, £10, £20, £50, £100, trans_Id) VALUES (7,'hello','2010-09-15 01:20:06','2','2','2','2','2','hello')";
It looks like you simply need to escape the column names that start with £ with backticks:
INSERT INTO atm_data (ID, ... `£10`, `£20`, `£50`, `£100` ...
Test case:
CREATE TABLE tb (`£10` int);
Query OK, 0 rows affected (0.05 sec)
INSERT INTO tb (£10) VALUES (10);
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 '?10) VALUES (10)' at line 1
INSERT INTO tb (`£10`) VALUES (10);
Query OK, 1 row affected (0.00 sec)