我在表格中有以下列
type | date_1 | date_2 | date_3
类型列是
ENUM('1','2','3')
我需要按日期列进行排序,但要在每一行使用基于type
列的相应列。
答案 0 :(得分:2)
在You can pass button click id as a parameter in querystring and then access that querystring value from other page.
Here is code for your page1:
<asp:Button ID="Button1"
runat="server"
Text="Cycle Test 1"
class="studentdetbtn"
OnClientClick="return OpenPage(this);" />
<script>
function OpenPage(elemt) {
var id = $(elemt).attr("id");
window.open('internalmark.aspx?param=' + id , 'Internal Mark');
}
</script>
Here is code for your page2 i.e "internalmark.aspx":
<script>
$(document).ready(function () {
var qs = getQueryStrings();
var GetButtonId= qs["param"];
alert("here is the button id: "+ GetButtonId)
});
function getQueryStrings() {
var assoc = {};
var decode = function (s)
{
return
decodeURIComponent(s.replace(/\+/g, " "));
};
var queryString = location.search.substring(1);
var keyValues = queryString.split('&');
for (var i in keyValues) {
var key = keyValues[i].split('=');
if (key.length > 1) {
assoc[decode(key[0])] = decode(key[1]);
}
}
return assoc;
}
</script>
中使用case
表达式来获取正确的值:
order by
答案 1 :(得分:1)
尝试类似
的内容SELECT *
FROM your_table
ORDER BY IF(type='1', date_1, IF(type='2', date_2, date_3))