When I use this mysql code
update catalog_product_entity_decimal
set value = "6.0000"
where attribute_id = 75 and
entity_in ( SELECT
product_id
from `catalog_category_product`
WHERE category_id =37 );
i'm getting this 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 product_id from `catalog_category_product` ' at line 4
I couldn't figure out what's wrong with my query. Can someone tell me what's wrong?
Thank you
You are missing the IN clause after entity_in. Use this:
update catalog_product_entity_decimal
set value = "6.0000"
where attribute_id = 75 and
entity_id IN ( SELECT
product_id
from `catalog_category_product`
WHERE category_id =37 );
I think catalog_category_product will not contain the ' symbol.
Try the query without using the ' symbol
You missed = OR in in the query
Related
I have a column discount_amount, if there's no SUM(discount_amount) (NULL) THEN it's zero (0).
I wrote the query with this
SELECT COALESCE(SUM(discount_amount)
FROM order_discount
WHERE order_discount.discount_type_id = 6
AND order_discount.order_match_id = om1.id, 0);
but I get an error
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 order_discount WHERE order_discount.discou' at line 2
You seem to want:
SELECT COALESCE(SUM(discount_amount), 0)
FROM order_discount
WHERE order_discount.discount_type_id = 6 AND order_discount.order_match_id = om1.id;
This has to be part of bigger query, where derive table om1 is defined somehow.
Alternatively, you can COALESCE() the result of the subquery like this:
COALESCE(
(
SELECT SUM(discount_amount)
FROM order_discount
WHERE order_discount.discount_type_id = 6 AND order_discount.order_match_id = om1.id
),
0
)
Again, this only makes sense if included in a bigger query.
I try to execute the query but get an error. This is my query:
UPDATE
prepares_for_exam
SET
prepares_for_exam.exam_id = product.id
FROM
prepares_for_exam,
product
WHERE
prepares_for_exam.id = product.prepares_for_exam_id
and I get the 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 'FROM prepares_for_exam, product WHERE prepares_for_exam.id = product.prepares_fo' at line 1
I did the Update Query 100-times with an FROM clause and never had problems... Whats my fault?!?
You are using the SQL-Server syntax. In MySQL it is a little bit different.
UPDATE
prepares_for_exam
JOIN
product
ON
prepares_for_exam.id = product.prepares_for_exam_id
SET
prepares_for_exam.exam_id = product.id
UPDATE
prepares_for_exam
SET
prepares_for_exam.exam_id = (select product.id FROM
prepares_for_exam JOIN product on prepares_for_exam.id = product.prepares_for_exam_id)
SELECT `register`.`first_name`, `register`.`last_name`
JOIN `register`
ON `like_check`.`user` = `register`.`id`
WHERE `like_check`.`look` = '31'
I am using above given query and I am getting 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 'JOIN register ON like_check.user = register.id WHERE like_check.`loo'
like_check:-
id | user | look
register:-
id | first_name | last_name | email
Can anybody help me to solve this.
This is what it should be. You are missing the from clause.
SELECT
`register`.`first_name`,
`register`.`last_name`
from register
JOIN `like_check` ON `like_check`.`user` = `register`.`id`
WHERE `like_check`.`look` = '31'
You're missing the from clause:
SELECT `register`.`first_name`, `register`.`last_name`
FROM `like_check`
JOIN `register` ON `like_check`.`user` = `register`.`id`
WHERE `like_check`.`look` = '31'
i try to remove duplicate records from table
my sql query is :
DELETE FROM products_description AS t1 WHERE EXISTS (
SELECT 'products_id', 'site_language_id'
FROM products_description AS t2
WHERE t2.products_id = t1.products_id
AND t2.site_language_id = t1.site_language_id
);
it give this 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 t1
where exists (select 'products_id','site_language_id' from products_desc' at line 1
i don't know what is missing ?
To delete all records which have duplicates
DELETE FROM products_description
WHERE product_id IN (
SELECT product_id FROM( Select product_id,site_language_id
From products_description
Group By product_id,site_language_id
Having Count(*)>1
) As X
)As Y
MySQL is complaining since there is a syntax error. Try replacing the quote (') with a backtick (`).
Be careful though! The query will then work but will delete all rows rather than just duplicates....
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