mysql工作台选择并选择发布
我不知道为什么这让我困惑。。奇怪的是,我看到的关于如何做到这一点的东西在工作台中显示为错误。。 所以我想先选择进入var,然后选择退出。。然后使用var进行更新。。但是 它永远不起作用。。所以我发现你不得不做这件事。。现在上面显示了红色的x。。怎么了mysql工作台选择并选择发布,mysql,select,select-into,Mysql,Select,Select Into,我不知道为什么这让我困惑。。奇怪的是,我看到的关于如何做到这一点的东西在工作台中显示为错误。。 所以我想先选择进入var,然后选择退出。。然后使用var进行更新。。但是 它永远不起作用。。所以我发现你不得不做这件事。。现在上面显示了红色的x。。怎么了 use reunionfunfacts; drop procedure if exists reunionfunfacts.getTrueFact; DELIMITER // CREATE PROCEDURE getTrueFact(i
use reunionfunfacts;
drop procedure if exists reunionfunfacts.getTrueFact;
DELIMITER //
CREATE PROCEDURE getTrueFact(in in_idperson int)
BEGIN
DECLARE _idtrue_fact int;
select
idtrue_fact into _idtrue_fact,
fact_text
from
reunionfunfacts.true_fact
where
in_idperson = idperson and fact_in_use = 0 or fact_in_use is null
order by rand() limit 1;
update reunionfunfacts.true_fact set fact_in_use=1 where idtrue_fact=_idtrue_fact;
END
//
DELIMITER ;
你有两列,所以你必须像这样添加到变量中 但我不知道你的事实文本是否足够
drop procedure if exists reunionfunfacts.getTrueFact;
DELIMITER //
CREATE PROCEDURE getTrueFact(in in_idperson int)
BEGIN
DECLARE _idtrue_fact int;
DECLARE _fact_text TEXT;
select
idtrue_fact ,
fact_text
INTO _idtrue_fact, _fact_text
from
reunionfunfacts.true_fact
where
in_idperson = idperson and fact_in_use = 0 or fact_in_use is null
order by rand() limit 1;
update reunionfunfacts.true_fact set fact_in_use=1 where idtrue_fact=_fact_text;
END
//
DELIMITER ;
SQLServer和MySQL是完全不同的产品。您不能将MySQL Workbench与SQL Server一起使用,也不能将SSMS与MySQL一起使用。您的标题是“MySQL Workbench”,但您的标记是
SQL Server
。是否尝试将一列选择为两个变量?你能不能把“所以我想先选择var,然后再选择out”改成“事实文本有什么用?你似乎不使用它。我不是在混合sql和mysql。”。。都是mysql。我没有尝试为sql server添加标记。。很抱歉所以我想将idtrue\u事实选择到一个var中,然后选择出事实文本。因此,sp应该只将事实文本返回给我的c程序,并且sp应该使用idtrue事实更新表。在同一个查询中,您不能同时执行这两项操作,因为select into也不会返回结果集。您可能需要2个查询。那么这是全部还是全部?你不能从正常值中选择一个,然后将一个选择到变量中?正如你所看到的,我把两个都放在变量中,所以使用两个或无都不重要