SQL找不到结果 [英] SQL not finding results

查看:47
本文介绍了SQL找不到结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此查询当前未返回任何结果,应该返回.您能看到此查询有什么问题吗

This query currently is returning no results, and it should. Can you see anything wrong with this query

字段标题为NEED_2_TARGET,ID和CARD

field title are NEED_2_TARGET, ID, and CARD

NEED_2_TARGET =整数

NEED_2_TARGET = integer

CARD =字符串

ID =整数

name的值为'Ash Imp'

value of name is 'Ash Imp'

{this will check if a second target is needed}
//**************************************************************************
function TFGame.checkIf2ndTargetIsNeeded(name: string):integer;
//**************************************************************************
var
  targetType : integer; //1 is TCard , 2 is TMana , 0 is no second target needed.
begin
    TargetType := 0;
    Result := targetType;
       with adoquery2 do
        begin
          close;
          sql.Clear;
          sql.Add('SELECT * FROM Spells WHERE CARD = '''+name+''' and NEED_2_TARGET = 1');
          open;
        end;

        if adoquery2.RecordCount < 1 then
          Result := 0
       else
         begin
           Adoquery2.First;
           TargetType := adoquery2.FieldByName(FIELD_TARGET_TYPE).AsInteger;
           result := TargetType;
         end;

end;

sql db如下所示

sql db looks like below

ID  CARD    TRIGGER_NUMBER  CATEGORY_NUMBER QUANTITY    TARGET_NUMBER   TYPE_NUMBER PLUS_NUMBER PERCENT STAT_TARGET_NUMBER  REPLACEMENT_CARD_NUMBER MAX_RANDOM  LIFE_TO_ADD REPLACED_DAMAGE NEED_2_TARGET   TYPE_OF_TARGET
27  Ash Imp     2                   2          15             14                                                                                                                                  1             1

推荐答案

这是或曾经是

With Adoquery2 do
begin
...
end

在sql中使用name时,实际上得到的是adoquery2.name而不是var名称.我通过将name更改为Cname之后再没有其他问题来解决此问题.

when using name in the sql, it was really getting adoquery2.name not the var name. I fixed this by changing name to Cname had no more issues after that.

这篇关于SQL找不到结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆