Comments - TSQL To Maria DB SQL

3 years ago Ian Gilfillan

Your formatting of the code in the question was certainly hard to read, but I've fixed that for you :) FYI, you can preview the comment, and use the "editing help" link visible when you are typing. In this case, wrapping <<code>> or <<sql>> tags around your sample code makes it much more readable.

As to the question, the way you've pasted it is definitely broken - you have two CREATE TABLE statements inside of each other. Presumably a copy and paste error. But even if you take the inner query there are errors. When you enter this in the MariaDB client you'll see an error, and this helps you find where the problem is. The first error would be:

ERROR 1064 (42000): 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 ''Order'(...

This was answered in your previous question - the statement is again not correctly escaping the identifier - single quotes are not acceptable.

Your next error would be:

ERROR 1064 (42000): 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 'max) NULL...

That points you to the next error - look for where the string max etc. occurs in your query, and try see what could be wrong. In this case you have declared VARCHAR(max) which is not valid - it needs to be a number. Go through your statements in this way trying to identify your errors. If you are still unsure, use the Knowledge Base search to look up, for example, VARCHAR to get further help.

 
3 years ago Anthony Apollis

Why does this Maria DB syntax differ so much from MySQL and i found it in Xammp package which includes MySql. Im gettin error in this code also :(

SELECT date(o.created_datetime) as Date, od.product_uid as 'Product UID',

p.manufacturer Manufacturer, p.bmc BMC, p.brand Brand, od.label as SKUs, p.selling_unit as 'Unit of Measure',

ROUND(if(od.amended_quantity is not null, od.amended_quantity, od.quantity)) as 'Units Sold',

ROUND((if(od.amended_quantity IS NOT NULL, od.amended_quantity, od.quantity))*p.content,2) as 'Sales Volume',

ROUND((if(od.amended_quantity is not null, od.amended_quantity, od.quantity))*od.price,2) as 'Sales Value'

FROM order_detail od

left join order o on od.order_uid=o.uid

left join product p on od.product_uid=p.uid

and not od.label ='Plastic Bag'

and date(o.created_datetime) >= '2020-03-01'

 
3 years ago Anthony Apollis

Sorry, it's suppose to be orders and not order :)

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.