Template:Where clause

{{#if:{{{where|}}}|{{{where}}}|{{#lstsep:{{#tokenif:{{#replace:{{#if:{{{categoryname|}}}{{{category|}}}|{{{categoryname|}}},{{#lstmap:{{{category|}}}|,|@@@@|@@@@_card_data|,}}|Card_data}}{{#switch:{{lc:{{{format|}}} }}|standard=,Standard_format_cards|wild=,Standard_format_cards,Wild_format_cards|wild-only=,Wild_format_cards|classic|classic-only=,Classic_format_cards}}| |_}}|@@@@| {{Holds all of|category|@@@@}} }}~{{#switch:{{lc:{{{bg_type|}}} }}|all=|either=Cards.bg_type IS NOT NULL|none=Cards.bg_type IS NULL|regular=Cards.bg_type="Regular"|gold=Cards.bg_type="Gold"|Cards.bg_type IS NULL}}~{{#if:{{{name|}}}|({{#lstmap:{{{name|}}}|\!\!|@@@@|Cards.name=CONCAT( {{#lstmap:@@@@|\_|$$$$| {{#lstmap:$$$$||%|"%"|,}} |," ",}} )|\_OR\_}})|}}~{{#if:{{{tier|}}}|({{#if:{{#pos:{{{tier}}}|~}}|Cards.tier>="{{#explode:{{{tier}}|~|0}}" AND Cards.tier<="{{#explode:{{{tier}}}|~|1}}"|Cards.tier="{{{tier}}}"}})|}}~{{#if:{{{type|}}}|({{#lstmap:{{{type|}}}|\!\!|@@@@|Cards.type=CONCAT( {{#lstmap:@@@@|\_|$$$$| {{#lstmap:$$$$||%|"%"|,}} |," ",}} )|\_OR\_}})|}}~{{#if:{{{subtype|}}}|({{#lstmap:{{{subtype|}}}|\!\!|@@@@|Cards.subtype=CONCAT( {{#lstmap:@@@@|\_|$$$$| {{#lstmap:$$$$||%|"%"|,}} |," ",}} )|\_OR\_}})|}}~{{#if:{{{class|}}}|{{Holds any of|class|{{#lstsep:{{{class|}}}|\!\!|,}}|}}|}}~{{#if:{{{multiclass|}}}|({{#lstmap:{{{multiclass|}}}|\!\!|@@@@|Cards.multiclass=CONCAT( {{#lstmap:@@@@|\_|$$$$| {{#lstmap:$$$$||%|"%"|,}} |," ",}} )|\_OR\_}})|}}~{{#if:{{{rarity|}}}|({{#lstmap:{{{rarity|}}}|\!\!|@@@@|Cards.rarity=CONCAT( {{#lstmap:@@@@|\_|$$$$| {{#lstmap:$$$$||%|"%"|,}} |," ",}} )|\_OR\_}})|}}~{{#if:{{{mana|}}}|({{#if:{{#pos:{{{mana}}}|~}}|Cards.cost>="{{#explode:{{{mana}}}|~|0}}" AND Cards.cost<="{{#explode:{{{mana}}}|~|1}}"|Cards.cost="{{{mana}}}"}})|}}~{{#if:{{{attack|}}}|({{#if:{{#pos:{{{attack}}}|~}}|Cards.attack>="{{#explode:{{{attack}}}|~|0}}" AND Cards.attack<="{{#explode:{{{attack}}}|~|1}}"|Cards.attack="{{{attack}}}"}})|}}~{{#if:{{{health|}}}|({{#if:{{#pos:{{{health}}}|~}}|Cards.hp>="{{#explode:{{{health}}}|~|0}}" AND Cards.hp<="{{#explode:{{{health}}}|~|1}}"|Cards.hp="{{{health}}}"}})|}}~{{#if:{{{heroichealth|}}}|({{#if:{{#pos:{{{heroichealth}}}|~}}|Cards.heroichp>="{{#explode:{{{heroichealth}}}|~|0}}" AND Cards.heroichp<="{{#explode:{{{heroichealth}}}|~|1}}"|Cards.heroichp="{{{heroichealth}}}"}})|}}~{{#if:{{{gold|}}}|({{#switch:{{lc:{{{gold}}} }}|true=Cards.has_gold=1|#default=Cards.has_gold=0}})|}}~{{#if:{{{ability|}}}|{{Holds any of|ability|{{#lstsep:{{{ability|}}}|\!\!|,}}|}}|}}~{{#if:{{{artist|}}}|({{#lstmap:{{{artist|}}}|\!\!|@@@@|Cards.artist=CONCAT( {{#lstmap:@@@@|\_|$$$$| {{#lstmap:$$$$||%|"%"|,}} |," ",}} )|\_OR\_}})|}}~{{#if:{{{voiceactor|}}}|({{#lstmap:{{{voiceactor|}}}|\!\!|@@@@|Cards.voice_actor=CONCAT( {{#lstmap:@@@@|\_|$$$$| {{#lstmap:$$$$||%|"%"|,}} |," ",}} )|\_OR\_}})|}}~{{#if:{{{tag|}}}|{{Holds any of|tag|{{#lstsep:{{{tag|}}}|\!\!|,}}|}}|}}~{{#if:{{{hiddentag|}}}|{{Holds any of|hiddentag|{{#lstsep:{{{hiddentag|}}}|\!\!|,}}|}}|}}~{{#if:{{{voiceactor|}}}|({{#lstmap:{{{voiceactor|}}}|\!\!|@@@@|Cards.voice_actor=CONCAT( {{#lstmap:@@@@|\_|$$$$| {{#lstmap:$$$$||%|"%"|,}} |," ",}} )|\_OR\_}})|}}~{{#if:{{{collectible|}}}|({{#switch:{{lc:{{{collectible}}} }}|true=Cards.collectible=1|#default=Cards.collectible=0}})|}}~{{#if:{{{set|}}}|{{Holds any of|set|{{#lstsep:{{{set|}}}|\!\!|,}}|}}|}}~|~|\_AND\_}} }}