如果我要在 SQL 数据库查询,根据已经有的 ID 查询出表数据,再根据表数据的一个字符串分割出 ID 作为条件查询出另外一个表格的数据怎么写?
2条回答 默认 最新
自在猫先生 2022-02-11 08:59关注declare @Id nvarchar(32)=null, declare @Result nvarchar(128)=null declare @StrId nvarchar(32)=null select @Id=id from table where id=@Id set @StrId =substring(@Id,1,4) select @Result =查询字段 from table2 where id=@StrId Raiserror(@Result,16,1);评论 打赏 举报 编辑记录解决 1无用