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
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 have this script calculates profit
Steps :
barangbeli = harsat / diameter
p1 = barangbeli * 10
p2 = prof / 100
result = barangbeli + profit;
thanks
CREATE VIEW tbkeluar as
SELECT mbarang.kdbrg, mbarang.nmbrg, mbarang.spek,if(SUM(bkeluar.qty), SUM(bkeluar.qty), 0)as qty,(tbmasuk.harsat/mbarang.diameter) as hargabeli, ((hargabeli*10)/100 )+hargabeli) as profit
LEFT JOIN bkeluar on mbarang.kdbrg = bkeluar.kdbrg group by mbarang.kdbrg
i have 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 ') as profit from mbarang
LEFT JOIN bkeluar on mbarang.kdbrg = bkeluar.kdbrg gro' at line 2
The error message you received should be helpful enough to know whats wrong.
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 ') as profit from mbarang LEFT JOIN bkeluar on mbarang.kdbrg = bkeluar.kdbrg gro' at line 2
Based from the error message, MySQL says that you have a syntax error because of this character ), with some characters appended for you to locate it: ) as profit from mbarang
As you can see from your SELECT statement, you have an extra )
SELECT mbarang.kdbrg
, mbarang.nmbrg
, mbarang.spek
,if(SUM(bkeluar.qty), SUM(bkeluar.qty), 0)as qty
,(tbmasuk.harsat/mbarang.diameter) as hargabeli
, ((hargabeli*10)/100 )+hargabeli) as profit
^ delete this extra parenthesis
Your SELECT statement (in CREATE VIEW) is missing its FROM clause. Do you mean FROM mbarang?
You're also probably missing at least one more JOIN; the table tbmasuk is mentioned in the SELECT clause, but isn't mentioned anywhere else in the statement.
so i get an error on the this sql query, but i can´t see my mistake myself:
SELECT group_members.group_id,
group_members.permissions,
group.group_name
FROM group_members,
group
WHERE group_members.group_id=group.group_id
AND group.group_id = 1
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 'group WHERE group_members.group_id=group.group_id AND group.group_id = 1
Thanks for your help!
Group is a reserved word in MySQL either enclose it in backticks "`" or better yet do not use it as a table name
SELECT group_members.group_id, group_members.permissions, `group`.group_name
FROM group_members, `group`
WHERE group_members.group_id=`group`.group_id
AND `group`.group_id = 1
Try this
SELECT group_members.group_id, group_members.permissions, `group`.group_name
FROM group_members, group
WHERE group_members.group_id=`group`.group_id
AND `group`.group_id = 1
I go this error message when I run this query
SELECT name,state FROM customers WHERE state IN ('CA','NC','NY')
Error
SQL query: Documentation
SELECT name, state
FROM customers
WHERE state IN(
'CA', 'NC', 'NY'
)
LIMIT 0 , 30
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 '‌in ('CA','NC','NY') LIMIT 0, 30' at line 1
I has a look there http://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html but I still can't find the reason why
Thank you
Remove the = after IN
SELECT name, state FROM customers
WHERE state IN ('CA','NC','NY')
SELECT name,state FROM customers WHERE state IN ('CA','NC','NY')
You can not use the '=' with an IN
I tried to copy your query and run it in MySQL
You have some strange "hidden" character before IN
If you delete it, then everything works fine
I found a very similar quesiton on here copied the code changed as required and it won't run under MySQL:
SELECT
id_manufacturer,
id_partname,
id_model,
cnumber,
COUNT (*)
FROM
rpi_consumables
GROUP BY
id_manufacturer, id_partname, id_model, cnumber
HAVING COUNT(*) > 1
Anyone have any ideas as to why the syntax fails?
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 '*) from rpi_consumables group by
id_manufacturer, id_partname, id_mode' at line 6
There should be no space between COUNT and (*).
SELECT
id_manufacturer,
id_partname,
id_model,
cnumber,
COUNT(*) /* This is where the space needs to be removed */
FROM
rpi_consumables
GROUP BY
id_manufacturer, id_partname, id_model, cnumber
HAVING COUNT(*) > 1