现在,我在MySQL中创建了一个表设为PinDistance
,列为PinCode1
、PinCode2
、Distance
.
我有一个这样的记录.
|PinCode1|PinCode2|距离|
|移动400001美元|移动400002美元|移动通信设备2移动通信设备|
|收入400004美元|收入400001美元|收入5.5亿美元|
Now I want to pass two pincodes say '400001' and '400002'
and I want to Distance in response in a query such that query checks both columns and get the data.
Currently I am doing like the following
Select Distance from PinDistance where PinCode1 = '400001' and PinCode2 = '400002'
- IF I get data from this then I stop here else I pass another query interchanging pincode values simultaneously.
Select Distance from PinDistance where PinCode1 = '400002' and PinCode2 = '400001'
有没有更好的办法?