I want to select data from table using native query and DATE_ADD but always I got an errors,
this is my sql request:
$qb = $this->_em->createNativeQuery("select Coalesce (sum(p.nb_sms*p.nb_destination),0) as multiplesms , sum(p.nb_fax) as nbFax, sum(p.nb_Mail) as nbMail FROM push p WHERE p.id_user=$id and DATE_ADD(p.date_send,7,'DAY') > CURRENT_DATE() and p.statut>0 order by p.date_send Desc", $rsm);
I got an error
SQLSTATE[42000]: Syntax error or access violation: 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 '7,'DAY') > CURRENT_DATE() and p.statut>0 order by p.date_send Desc' at line 1
any idea please
mistake in DATE_ADD function syntax
change DATE_ADD(p.date_send,7,'DAY') to DATE_ADD(p.date_send, INTERVAL 7 DAY)
Related
I'm using two tables in mysql workbench 8 and run server mariadb in xaamp
When I try create a Index in a table show this message:
Operation failed: There was an error while applying the SQL script to the database.
Executing:
ALTER TABLE `bd_dev`.`telefonecliente`
ADD INDEX `idCliente` (`idCliente` ASC) VISIBLE;
;
ERROR 1064: 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 2
SQL Statement:
ALTER TABLE `bd_dev`.`telefonecliente`
ADD INDEX `idCliente` (`idCliente` ASC) VISIBLE
someone know can I fix it? thank you
Remove the VISIBLE and it should work. Default is VISIBLE.
ALTER TABLE `bd_dev`.`telefonecliente`
ADD INDEX `idCliente` (`idCliente` ASC) ;
Tested this on Mariadb 10.4.21-MariaDB.
I wanted to fetch the currently executing queries in Teradata and when I ran the below SQL and I got the error message as 'Failed 9881 : Function 'MonitorSQLText' called with an invalid number or type of parameters'. I am using TD 14.10
SELECT * FROM TABLE (MonitorSQLText(-1, '*', 0)) AS T2;
Please help me with this query.
MonitorSQLText can only be applied to a single session.
To get info for all sessions you must use MonitorSession(-1, '*', 0), when you do it in a Stored Procedure you can run it as a cursor and process each row.
I'm using SQlite in an Windows application (done with Visual C#); while inserting columns into the table I'm getting the following error:
Error while executing SQL query on database 'database': row value misused
The following is my insertion query:
INSERT INTO d_logindetails (userid,registration_no,logintime,expected_logout,machinesno,is_uploaded)VALUES (234,'1233',CURRENT_TIMESTAMP,(CURRENT_TIMESTAMP,'+60 minutes'),'s12452',0);
'+60 minutes' is just a string.
When used with the built-in date/time functions, it is interpreted as a modifier.
So to do this computation, you have to call such a function:
INSERT ... VALUES (..., CURRENT_TIMESTAMP, datetime('now', '+60 minutes'), ...);
I'm guessing it's the part where you have the following:
(CURRENT_TIMESTAMP,'+60 minutes')
Personally I'd just do:
dateadd(HOUR, 1, getdate())
I need to change my Oracle query to SQLite.
It is some kind of calendar.
Oracle query, which works fine:
SELECT TRUNC(sysdate,'DD') - level AS d
FROM dual
CONNECT BY level <= 180
SQLite query, which I have written:
WITH RECURSIVE
dates(day_date) AS (
SELECT date('now','-180 day')
UNION ALL
SELECT day_date+1
FROM dates WHERE day_date < date('now')
)
select * from dates;
It throws an error, when I am executing it.
Error while executing query: near "WITH": syntax error
What is wrong with my code? I used this page to check syntax: https://www.sqlite.org/lang_with.html
Common table expressions are not available before SQLite version 3.8.3.
I have the below script in the Source Editor in a SSIS package and I get an error. I change to a Select * and it works. I'm not sure why this is not working. It works in P/SQL. Any help would be appreciated!
This works in my package:
select * from Test
This does not work in my package (but works in PL/SQL) and I get the below error.
select * from (select id, color, shape,
dense_Rank () Over (Partition By id order by id desc as SeqRank)
) x
Error: 0xC0202009 at Data Flow Task, OLE DB Source [111]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14.
Best approach for this questions is instead of creating a subquery one could create a CTE. A CTE is compatiable with SSIS.