PostgreSQL插入x次2个相同的行

时间:2015-11-12 14:48:24

标签: sql postgresql multidimensional-array sql-insert

我有下表:

INSERT

您是否有一个解决方案,用3 setting_name中的这些值以及包含setting_value和关联默认INSERT INTO user_setting (user_id, setting_name, setting_value) ( SELECT 1, params[1], params[2] FROM unnest(ARRAY[['color','000000'],['date','aammjj']]) AS params ) INSERT INTO user_setting (user_id, setting_name, setting_value) ( SELECT 1, params[1], params[2] FROM unnest(ARRAY[['color','000000'],['date','aammjj']]) AS params ) INSERT INTO user_setting (user_id, setting_name, setting_value) ( SELECT 3, params[1], params[2] FROM unnest(ARRAY[['color','000000'],['date','aammjj']]) AS params ) 的数组填充表格? 我在考虑:

input.border=true;
input.restrict="0-9.";

var cat:int;

Enter.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent) {
    cat=int(input);
    switch(cat) { 
    case 1: 
        output.text="74-95 mph or 64-82 kt or 119-153 km/hr";
        break; 
    case 2: 
        output.text="96-110 mph or 83-95 kt or 154-177 km/hr"; 
        break; 
    case 3: 
        output.text="111-130 mph or 96-113 kt or 178-209 km/hr"; 
        break; 
    case 4: 
        output.text="131-155 mph or 114-135 kt or 210-249 km/hr"; 
        break; 
    case 5: 
        output.text="greater than 155 mph or 135 kt or 249 km/hr"; 
        break; 
    default:
        output.text="Out of Range!"
        break;
    }
}

1 个答案:

答案 0 :(得分:0)

select user_id, p1, p2
from
    (values (1),(2),(3)) u (user_id)
    cross join
    (values ('color','000000'),('date','aammjj')) as params (p1, p2)
;
 user_id |  p1   |   p2   
---------+-------+--------
       1 | color | 000000
       1 | date  | aammjj
       2 | color | 000000
       2 | date  | aammjj
       3 | color | 000000
       3 | date  | aammjj