我试着在google和stackoverflow上搜索一个庞大代码的解决方案。对于mysql数据库,我想检索大量数据。这个数据库不是我们自己设计的,而是一个外部公司,所以我不能为缺乏数据库工程技能负责。
问题是,我必须选择52列,所有列的列名都是递增的(如示例所示)。
SELECT results.tc_serial AS "SerialNo",
results.total_result AS "TotalResult",
results.eval_01_id AS "Measurement1_ID",
eval1_parameter.tag AS "Measurement1_TAG",
eval_result1.value AS "Measurement1_VAL",
eval2_parameter.tag AS "Measurement2_TAG",
eval_result2.value AS "Measurement2_VAL",
eval3_parameter.tag AS "Measurement3_TAG",
eval_result3.value AS "Measurement3_VAL",
eval4_parameter.tag AS "Measurement4_TAG",
eval_result4.value AS "Measurement4_VAL",
eval5_parameter.tag AS "Measurement5_TAG",
eval_result5.value AS "Measurement5_VAL",
eval6_parameter.tag AS "Measurement6_TAG",
eval_result6.value AS "Measurement6_VAL"
FROM ga_35_4599_ipc_01.test_results results
JOIN ga_35_4599_ipc_01.test_parameters test_parameter ON
results.test_parameter_id = test_parameter.id
JOIN ga_35_4599_ipc_01.eval_windows_results eval_result1 ON
results.eval_01_id = eval_result1.id
JOIN ga_35_4599_ipc_01.eval_windows_results eval_result2 ON
results.eval_02_id = eval_result2.id
JOIN ga_35_4599_ipc_01.eval_windows_results eval_result3 ON
results.eval_03_id = eval_result3.id
JOIN ga_35_4599_ipc_01.eval_windows_results eval_result4 ON
results.eval_04_id = eval_result4.id
JOIN ga_35_4599_ipc_01.eval_windows_results eval_result5 ON
results.eval_05_id = eval_result5.id
JOIN ga_35_4599_ipc_01.eval_windows_results eval_result6 ON
results.eval_06_id = eval_result6.id
JOIN ga_35_4599_ipc_01.eval_windows_para eval1_parameter ON
test_parameter.eval_01_id = eval1_parameter.id
JOIN ga_35_4599_ipc_01.eval_windows_para eval2_parameter ON
test_parameter.eval_02_id = eval2_parameter.id
JOIN ga_35_4599_ipc_01.eval_windows_para eval3_parameter ON
test_parameter.eval_03_id = eval3_parameter.id
JOIN ga_35_4599_ipc_01.eval_windows_para eval4_parameter ON
test_parameter.eval_04_id = eval4_parameter.id
JOIN ga_35_4599_ipc_01.eval_windows_para eval5_parameter ON
test_parameter.eval_05_id = eval5_parameter.id
JOIN ga_35_4599_ipc_01.eval_windows_para eval6_parameter ON
test_parameter.eval_06_id = eval6_parameter.id
order by results.time desc
limit 10;
有没有一种方法可以通过如下方式循环选择:
FOR (INT i = 1; i <= 52; i++)
SELECT Column_[i]
FROM tstDatabase
再一次,如果我看了一些完美的例子,我道歉。从我的代码中可以看出,我也不是(我的)sql天才。
暂无答案!
目前还没有任何答案,快来回答吧!