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 'where paid_date between" January1,2021" and "Getdate()"' at line 5. Can someone help me fix my SQL?
select DATEDIFF(paid_date, cart_shipped_date) Days_till_paid, stat_completed_carts.*
from stat_completed_carts
where billing_method_id="30"
where paid_date between" January1,2021" and "Getdate()";
Related
SELECT sma_quotes.customer as name,
sma_quotes.date as date,
sma_quotes.selecttype as type,
sma_quotes.biller_id as bl_id,
sma_quotes.volume as volume,
sma_quotes.containernumber as cn_no,
sma_quotes.grand_total as total,
sma_sales.paid as paid
FROM sma_quotes
JOIN sma_sales ON sma_sales.quote_id = sma_quotes.id
WHERE name IS 'Everbest Foods'
Error
SQL query: Documentation
MySQL said: Documentation
#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 ''Everbest Foods' LIMIT 0, 25' at line 1
There is no LIMIT in your query, so the error message is suspicious.
However, you want =, not IS:
WHERE sma_quotes.customer = 'Everbest Foods'
i did this in mysql
Select max(bid) FROM data WHERE realtime BETWEEN (2017-05-11 11:29:00) AND (2017-05-11 11:30:00);
i show error as
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 '11:29:00) AND (2017-05-11 11:30:00) LIMIT 0, 25' at line 1
You should put the dates in single quotes
Select max(bid) FROM data WHERE realtime BETWEEN ('2017-05-11 11:29:00') AND ('2017-05-11 11:30:00');
i want to convert this mysql query to laravel. please advice
below is mysql code i tried
select
user_id,time_sheet_id,role_id,
TIME_FORMAT(SEC_TO_TIME(sum(TIME_TO_SEC(TIMEDIFF( shift_end_time, shift_start_time)))), "%h:%i") AS diff
FROM
shifts
group by
time_sheet_id
this is my laravel code, but its giving syntax errors
$findTotalhours = DB::table('shifts')
->select(DB::raw('user_id, time_sheet_id,role_id TIME_FORMAT(SEC_TO_TIME(sum(TIME_TO_SEC(TIMEDIFF( shift_end_time, shift_start_time)))), "%h:%i") AS diff'))
->groupBy('time_sheet_id')
->get();
UPDATE
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 '(SEC_TO_TIME(sum(TIME_TO_SEC(TIMEDIFF( shift_end_time, shift_start_time)))), "%h' at line 1 (SQL: select user_id, time_sheet_id,role_id TIME_FORMAT(SEC_TO_TIME(sum(TIME_TO_SEC(TIMEDIFF( shift_end_time, shift_start_time)))), "%h:%i") AS diff from `shifts` group by `time_sheet_id`)
I'm having trouble figuring out why this query does not work. Names have been sanitized as this is proprietary code.
QRY:
SELECT l.albert, o.ben, m.caleb, m.dennis, m.edgar
FROM octopus o, lorax l, monkey m
WHERE o.ben = l.ben
AND l.franklin= m.franklin
AND o.ben= :ben
ORDER BY l.albert DESC
LIMIT 1
Here is the error that I get:
MySQL 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 'QRY: SELECT l.albert, o.ben, m.caleb, m.dennis, m' at line 1
It seems like you have
"QRY: "
at the beginning of your query. It should start with
"SELECT ...
select count (*) from sales_order where date_format
(created_at,'%Y-%m-%d') >=
'2009-11-02' and date_format(created_at,'%Y-%m-%d')
<= '2010-12-08' and customer_id in
(14,1113,1115,1117,1132,1312,1345);
it gave me 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 '*) from sales_order where
date_format(created_at,'%Y-%m-%d') >= '2009-11-02' and' at line 1
Please let me know where is the problem
No space allow for count (*)
count(*)
The issue is with the space after COUNT. Do not use a space here. See this MySQL bug: Bug #2664 An extra space after Count in a Count(distinct... statement fails