我的例子是在这里:使用WHERE如果条件满足其他使用另一个WHERE
Select T1.*,
TC.country_name,
TS.state_name,
T1.address_type
From mtpd2_virtuemart_order_userinfos T1
Left Join mtpd2_virtuemart_countries TC On TC.virtuemart_country_id = T1.virtuemart_country_id
Left Join mtpd2_virtuemart_states TS On TS.virtuemart_state_id = T1.virtuemart_state_id
Where T1.address_type ='ST' OR T1.address_type = 'BT'
And T1.virtuemart_order_id /*SELECTED_ID_LIST*/
我要找的逻辑是使用(WHERE T1.address_type='ST')
如果在细胞内的字符串是“ST”以其它方式使用(WHERE T1.address_type='BT')
我删除了我不兼容的数据库标签。随意为您真正使用的数据库添加标签。我想你只是想''在':'在哪里T1.address_type IN('ST','BT')'。 –
在一行包含'ST'的情况下,另一个'BT'选择'ST'行,但如果行中没有ST,请选择'BT'行,这是唯一的选择。 –
我应该提到,我们一起有'BT'和'ST'的情况。这意味着我想,如果有2行一包含'ST'另一个'BT',那么只选择'ST'(其中T1.address_type ='ST')但如果我们只有一行,它是'BT',然后选择' BT' –