i trie to run this statement:
CREATE DEFINER=`daimler_bkUser`#`%` PROCEDURE `expatSuchen`(IN SUCHBEGRIFF VARCHAR(60))
BEGIN
Select * from expats where Last_Name LIKE CONCAT('%', SUCHBEGRIFF , '%');
END
But MySQL gives me the following error:
java.sql.SQLSyntaxErrorException: 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 '()' at line 1
Related
i got an error while im trying to execute query views in mysql version 5.7.19
Here is my query :
CREATE ALGORITHM=UNDEFINED DEFINER=`acc_webdev`#`%` SQL SECURITY DEFINER VIEW `view_dash_total` AS
SELECT
COUNT(0) AS `jumlah`,
SYSDATE() AS `tanggal`
FROM `table_laporan`
WHERE (STR_TO_DATE(`table_laporan`.`dt_added`,'%d-%m-%Y') < (SYSDATE() + INTERVAL - (1)DAY))$$
and got 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 '$$' at line 6
but in mysql 5.1.25, there's no error when i execute the query above
please help me out
Either prepend your DDL with DELIMITER $$ or just change your delimiter to ;.
Read more about delimiters here
Try This:
CREATE VIEW `view_dash_total` AS
SELECT
COUNT(0) AS `jumlah`,
SYSDATE() AS `tanggal`
FROM `table_laporan`
WHERE (STR_TO_DATE(`table_laporan`.`dt_added`,'%d-%m-%Y') < (SYSDATE() + INTERVAL - (1)DAY));
I'm creating a stored procedure using phpmyadmin for mysql 5.5.55 .
INSERT INTO drama_ (value1,value2,value3,value4,value5,value6)
VALUES (val1,val2,0,0,0,0);
SELECT LAST_INSERT_ID();
but i'm getting a syntax error in SELECT LAST_INSERT_ID();
EDIT :
You have an error your SQL syntax: check the manual that corresponds to your MYSQL server version for the right syntax to use near 'SELECT LAST_INSERT_ID()' at line 4
I have 3 tables[table_a, table_b, dataz] in a my database, when I create a TRIGGER as follow,
CREATE TRIGGER trigz AFTER INSERT ON table_a
FOR EACH ROW
IF EXISTS (SELECT * FROM table_b WHERE table_b.uid = '123') THEN
INSERT INTO dataz
VALUES('123');
Getting ERROR as,
#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 '' at line 5
I don't understand what I am missing here...
I am using WAMP Server 2.4, anybody have solution ?
EDIT 1(for Nigel Ren)::
SQL :
CREATE TRIGGER trigz AFTER INSERT ON table_a FOR EACH ROW
IF EXISTS (SELECT * FROM table_b WHERE table_b.uid = 1) THEN
BEGIN
INSERT INTO dataz(userid) VALUES('123');
END;
END IF;
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 '' at line 4
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.
So im creating a procedure that accepts an argument namee and returns all users whose name is a substring of namee
create procedure search_res(IN namee varchar(50))
begin
select * from usr where name like %namee%;
end
But im getting the following 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 '%namee%; end' at line 3.
What is the correct syntax?
Use CONCAT function
select * from usr where name like CONCAT('%',namee,'%');