如何通过mysql设置变量select的输出?

How to Set ouput of select in variable by mysql?

我想对设置为变量@x 的产品 ID 进行计数。在查询 phpmyadmin 时没有程序或函数。 但是错误

set @x=70489;
    set @y = select count(`product_id`) from `oc_product` where  `language_id`=2 and `product_id`=@x;

    select @x;
    SELECT @y;

SQL query: Documentation set @x=70489 set @y = select count(product_id) from oc_product where language_id=2 and product_id=@x; 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 'set @y = select count(product_id) from oc_product where `langua' at line 2

在select的开头和结尾添加()。

set @x=70489;
set @y = (select COUNT(*) from `oc_product` where  `language_id`=2 and `product_id`= @x);

SELECT @x;
SELECT @y;