我有以下数据库列及其值:
#1 Tree, Beer, Car
#2 Tree, Beer
#3 Car, House
我想用SQL SELECT查询这个表,输出应该是这样的:
<head>
所以我需要翻译单词中的数字代码。我如何在select子句中实现这一点?
谢谢!
答案 0 :(得分:1)
你可以试试
var onFocusTextTime;
var onFocusTextTimeForPrevTextBox = new Date().getTime();
function f1(e) {
onFocusTextTime = onFocusTextTimeForPrevTextBox;
onFocusTextTimeForPrevTextBox = new Date().getTime();
return onFocusTextTime;
}
function f2() {
var responceForAnswer = "";
var diff_result = "";
var onBlurTextTime = new Date().getTime();
var onFocusTextTime = f1();
diff_result = onBlurTextTime - onFocusTextTime;
var hours = diff_result / (1000 * 60 * 60);
var absoluteHours = Math.floor(hours);
var h = absoluteHours > 9 ? absoluteHours : '0' + absoluteHours;
var minutes = (hours - absoluteHours) * 60;
var absoluteMinutes = Math.floor(minutes);
var m = absoluteMinutes > 9 ? absoluteMinutes : '0' + absoluteMinutes;
var seconds = (minutes - absoluteMinutes) * 60;
var absoluteSeconds = Math.floor(seconds);
var s = absoluteSeconds > 9 ? absoluteSeconds : '0' + absoluteSeconds;
responceForAnswer = h + ':' + m + ':' + s;
console.log(responceForAnswer);
}
我是否应该提及可以通过将值放在不同列中来改进表设计。
如果您打算撤消当前的设计并拥有另一个设计,则需要进行测试,但我想这不是问题的目的。 ;)
答案 1 :(得分:0)
像这样硬编码将是非常糟糕的,但这是我现在唯一的方法
Select
COLUMN1,
CASE COLUMN2 WHEN 747 THEN 'TREE' WHEN 757 THEN 'BEER' WHEN 767 THEN 'CAR' WHEN 777 THEN 'HOUSE' END AS COLUMN2,
CASE COLUMN3 WHEN 747 THEN 'TREE' WHEN 757 THEN 'BEER' WHEN 767 THEN 'CAR' WHEN 777 THEN 'HOUSE' END AS COLUMN3,
CASE COLUMN4 WHEN 747 THEN 'TREE' WHEN 757 THEN 'BEER' WHEN 767 THEN 'CAR' WHEN 777 THEN 'HOUSE' END AS COLUMN4
FROM YOURTABLE