请问sql 专家一个检索语句的问题

1个回答

  • declare @sql varchar(4000);

    set @sql='select '+@n1+' count(*) from windbreaker where name like '''%'+@w1+'%''';

    exec @sql;

    set @sql='select '+@n2+' count(*) from windbreaker where name like '''%'+@w1+'%''';

    exec @sql;

    set @sql='select '+@n3+' count(*) from windbreaker where name like '''%'+@w1+'%'+@w2+'%'

    '';

    exec @sql;

    set @sql='select '+@n4+' count(*) from windbreaker where name like '''%'+@w2+'%'+@w2+'%'

    '';

    exec @sql;