Can anyone help me with this sql statement?
SELECT c.id AS 'cat_id', c.name, sol.id,
(SELECT f.id
FROM folders f, category_folder_mapping cf
WHERE cf.folder_id = f.id AND cf.category_id = c.id
ORDER BY f.id ASC LIMIT 1) AS 'folder_id'
FROM categories c
OUTER APPLY folderFirstSolution(folder_id) sol
ORDER by c.id ASC
My goal in this sql is to use the 'folder_id' as parameter for the folderFirstSolution() function. I always get an sql syntax error.
Please tell me what's wrong with this statement.
Thanks ahead.
(EDIT)
MYSQL 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 'OUTER APPLY folderFirstSolution(folder_id) sol
ORDER by c.id ASC
LIMIT 0, 25' at line 7
Related
SELECT op.*,
(op.total + op.total * 0.21) as price,
(SELECT p.`image` FROM oc_product` p WHERE op.product_id = p.product_id LIMIT 1) AS image
FROM `oc_order_product` op WHERE op.order_id = '80'
I can't found what is wrong with my query it's returning.
#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 'oc_order_productop WHERE op.order_id = '80' LIMIT 0, 25' at
line 3
Add a back tick before oc_product, so
SELECT p.`image` FROM oc_product`
should look like
SELECT p.`image` FROM `oc_product`
Please have a look at the below query.
SELECT sub_words.idwords, words_inc.idArticle
(
SELECT sub0.idwords, SUBSTRING_INDEX(GROUP_CONCAT(sub1.idwords), ',', 10) AS excl_words, COUNT(sub1.idwords) AS older_words_cnt
FROM words_learned sub0
LEFT OUTER JOIN words_learned sub1
ON sub0.userId = sub1.userId
AND sub0.order < sub1.order
WHERE sub0.userId = 1
GROUP BY sub0.idwords
) sub_words
INNER JOIN words words_inc
ON sub_words.idwords = words_inc.idwords
LEFT OUTER JOIN words words_exc
ON words_inc.idArticle = words_exc.idArticle
AND FIND_IN_SET(words_exc.idwords, sub_words.excl_words)
WHERE words_exc.idwords IS NULL
ORDER BY older_words_cnt
LIMIT 100
This gives the 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 'SELECT sub0.idwords, SUBSTRING_INDEX(GROUP_CONCAT(sub1.idwords), ',', 10) AS exc' at line 3
I checked the sub query individually and there was no error in the sub query! what is going on here?
You missed the from keyword
SELECT sub_words.idwords, words_inc.idArticle
FROM
( ...
I had this query
DELETE c FROM review_comments AS c
LEFT JOIN users AS u
ON u.user_id = c.user_id
WHERE c.comment = '{$comment}'
AND u.username = '{$user}'
LIMIT 1;
It did not work until I removed LIMIT 1;
It said: 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 1' at line 6
Is this the incorrect usage of LIMIT 1 in this instance? I had a same query without joining tables and LIMIT 1 worked fine?
I don't think LIMIT can be used with multi-table referenced DELETE statements in MySQL.
Im having issues trying to figure out this syntax error. Heres the SQL query:
SQL QUERY
SELECT oh.date_modified, oh.physicianNote, os.name AS status
FROM order oh
LEFT JOIN order_status os ON oh.order_status_id = os.order_status_id
WHERE oh.order_id = '118' AND os.language_id = '1'
ORDER BY oh.date_added ASC LIMIT 0,10
SQL 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 'order oh LEFT JOIN order_status os ON oh.order_status_id =
os.order_status_i' at line 2
Not really sure whats wrong with it.
ORDER is a reserved word. Quote it in backticks:
SELECT oh.date_modified, oh.physicianNote, os.name AS status
FROM `order` oh LEFT JOIN order_status os USING (order_status_id)
WHERE oh.order_id = '118' AND os.language_id = '1'
ORDER BY oh.date_added
LIMIT 0,10
"ORDER" is reserved word. This is error. Use the word order Quote in backticks
SELECT P.pID FROM Department D, Professor P
WHERE D.dID = P.dID
ORDER count(pID);
Mysql, keeps throwing an 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 'count(pID)
LIMIT 0, 30' at line 3
ORDER needs to be ORDER BY.
You are missing a BY.
The query should be:
SELECT P.pID FROM Department D, Professor P
WHERE D.dID = P.dID
ORDER BY count(pID);