【问题标题】:How to inquire the ith term in a table at postgreql?如何在 postgresql 中查询表中的第 n 个术语?
【发布时间】:2014-11-25 15:46:35
【问题描述】:

alldp 字符变化

"{K409,K358,K353,L059,R100,L050,K610,K352,K425,K661,I841,I848,Z433}"

我想查询第二学期(K358),所以我这样写select alldp[2] from table; 但它不起作用。我应该怎么办?

【问题讨论】:

    标签: arrays postgresql


    【解决方案1】:

    符号[2] 仅对数组有效。但是您的列是 varchar 列,而不是数组。

    您需要首先使用我向您展示过的相同函数将字符串转换为数组in your other question

    select (string_to_array(alldp, ','))[2]
    from the_table;
    

    【讨论】:

    • 非常感谢,我想在另一个与第二任期相同的表中找到其他人,之前,我这样写“select * from table1,table2 where table1.dp= table2. alldp[2]",所以我应该替换" select * from table1 ,table2 where table1.dp=table2.string_to_array(alldp,',')[2]"?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-08
    • 2020-01-15
    • 2015-01-23
    相关资源
    最近更新 更多