所以我在表中的随机行的指定列处获取值,使得:
var a = {
inside: {
value: 10,
furtherInside: {
value: 100
}
}
// may contain other objects, properties, etc.
};
console.log(getObjProperty(a, "inside.value")); // prints 10
console.log(getObjProperty(a, "inside.furtherInside.value")); // prints 100
这样可行。现在我想将整行的数据附加到结果行。例如,如果我的表是:
SELECT <COLUMN_NAME>
FROM ( SELECT <COLUMN_NAME>
FROM <SCHEMA>.<TABLE_NAME>
ORDER BY dbms_random.value )
WHERE rownum < <RANDOM_NUMBER>
如果我的指定列是B列,我的查询将返回:
Column A Column B Column C Column D
data1 data2 data3 data4
data5 data6 data7 data8
我希望它返回:
data2
data6
我假设它的东西像SELECT&lt; COLUMN_NAME&gt;,* ........?
答案 0 :(得分:1)
这应该有效,如果&lt; COLUMN_NAME&gt;在表格中是独一无二的:
SELECT r.<COLUMN_NAME>, t_append.* FROM (
SELECT <COLUMN_NAME> FROM <TABLE_NAME> t_random ORDER BY dbms_random.random ) r
inner join <TABLE_NAME> t_append on t_append.<COLUMN_NAME> = r.<COLUMN_NAME>
WHERE rownum <= dbms_random.value(1,<MAX_RANDOM_NUMBER_YOU_WANT>)
SELECT r.<COLUMN_NAME_1>, r.<COLUMN_NAME_2>, etc, t_append.*
FROM (
SELECT <COLUMN_NAME_1>, r.<COLUMN_NAME_2>, etc..
FROM <TABLE_NAME> t_random ORDER BY dbms_random.random ) r
inner join <TABLE_NAME> t_append on
t_append.<COLUMN_NAME_1> = r.<COLUMN_NAME_1>
AND t_append.<COLUMN_NAME_2> = r.<COLUMN_NAME_2>
AND etc...
WHERE rownum <= dbms_random.value(1,<MAX_RANDOM_NUMBER_YOU_WANT>)
再次......只有当您使用的列集唯一地标识表中的记录时,它才有效。