i was trying to display recent record.
i insert sql below in the recordset
SELECT `date`, `item_name`, `stock_invent`, `id_invent`,`num_in_out`
FROM `inventories` ORDER BY `id_invent` DESC LIMIT 3
But, how to make it display in table? because i got message
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 'LIMIT 0, 10' at line 1
SELECT date, item_name, stock_invent, id_invent, num_in_out
FROM inventories ORDER BY id_invent DESC LIMIT 0,3
Related
Hello, I have the following problem, I use the world.sql schema and I can't display my query in a descending way, I get the following 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 'DESC'
I can't find a way to solve the problem other than storing the result in a table and then applying DESC. Could someone guide me what I could do or where I could investigate?
SELECT la.language, la.Isofficial AS Isofficial ,SUM(country.Population * la.Percentage / 100) pop_tot FROM country INNER JOIN countrylanguage AS la ON la.countryCode = country.Code WHERE la.language != "Spanish" AND la.Isofficial = "T" GROUP BY la.Language DESC ;
'Prior to MySQL 8.0.13, MySQL supported a nonstandard syntax extension that permitted explicit ASC or DESC designators for GROUP BY columns...As of MySQL 8.0.13, the GROUP BY extension is no longer supported: ASC or DESC designators for GROUP BY columns are not permitted.' - https://dev.mysql.com/doc/refman/8.0/en/select.html
Replace
GROUP BY la.Language DESC;
with
GROUP BY la.Language
ORDER BY la.Language DESC;
Which will work in whatever MySQL server version you have.
BTW, I've tested the first syntax and it works well in version 5.5
I have query in my structure trying run in PHPMYADMIN. I am trying to run CUBE query for OLAP operation, this is my query :
SELECT QUARTER, REGION, SUM(SALES)
FROM salestable
GROUP BY CUBE (QUARTER, REGION)
I have also tried this query :
SELECT salestable.QUARTER, salestable.REGION, SUM(salestable.SALES)
FROM salestable
GROUP BY CUBE (salestable.QUARTER, salestable.REGION)
but it showing this 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 '(QUARTER, REGION) LIMIT 0, 25' at line 3
I tried to open the page to check syntax but it shows page not found.
I don't think MySQL supports CUBE as a GROUP BY modifier, but you can use WITH ROLLUP:
SELECT st.QUARTER, st.REGION, SUM(st.SALES)
FROM salestable st
GROUP BY st.QUARTER, st.REGION WITH ROLLUP;
I have recently upgraded my MariaDB 5.5 to MariaDB 10.3.14 specifically to be able to use the RANK() OVER function that was introduced after 10.2.
After going through the upgrade process, I still get the same syntax error message I was getting on 5.5.
#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 'RANK() OVER (
ORDER BY
at line 2
I'm trying to understand why after the upgrade I still get the same error.
Here's the query I'm using:
SELECT member_id, total_pts, correct_predictions, correct_goals
RANK() OVER (
ORDER BY
total_pts DESC,
correct_predictions DESC,
correct_goals DESC
) rank
FROM quiniela_1;
What am I doing wrong?
Put a comma after SELECT member_id, total_pts, correct_predictions, correct_goals so that your query reads:
SELECT member_id, total_pts, correct_predictions, correct_goals,
RANK() OVER (
ORDER BY
total_pts DESC,
correct_predictions DESC,
correct_goals DESC
) rank
FROM quiniela_1;
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 am writing the query to count the number of distinct values in the database table. So I wrote the query as:
select count ( distinct user_id ) as unique_users from 1_time_access;
I am getting 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 'distinct user_id ) as unique_users from 1_time_access' at line 1
Can anyone explain what am I missing?
Remove the space between count and the open parenthesis.
select count(distinct user_id) as unique_users from 1_time_access;