Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9028523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:00:17+00:00 2026-06-16T07:00:17+00:00

Possible Duplicate: convert MySQL SET data type to Postgres I have postgresql 8.4. I

  • 0

Possible Duplicate:
convert MySQL SET data type to Postgres

I have postgresql 8.4.

I am trying to build up a query without success. I would like to insert elements into an array if they are not exists in the conserning row.

TABLE “test”:

+------------------+------------------+
| id               | varchar(20)      |
| timestp          | timestamp        |
| place            | varchar(20)      |
| myarray[][]      | varchar[14][254] |
+------------------+------------------+

+---------+---------------------+-----------+----------------+
|  xyz    | 2010-01-01 10:10:10 | nowhere   |  "{abc,qwert}" |
+---------+---------------------+-----------+----------------+

So I would like to add “{fgh,gfdsa}” to myarray WHERE (id=’xyz’ AND timestp=”2010-01-01 10:10:10″ AND place=’nowhere’) IF it is not already in myarray

I tried something like this>

UPDATE test
SET myarray = array_append(wascon2,'{fgh,gfdsa}') 
WHERE (id='xyz' AND timestp="2010-01-01 10:10:10" AND place='nowhere'
AND NOT EXISTS 1 FROM test WHERE (myarray='{fgh,gfdsa}')));

This doesnt work, it will append the array every time when I call it.

+---+---------------------------+-------------------------------------------+
|xyz|2010-01-01 10:10:10|nowhere|{"{abc,qwert}","{fgh,gfdsa}","{fgh,gfdsa}"}|
+---+---------------------------+-------------------------------------------+

If think I should use >

myarray = ANY ('{fgh,gfds}'::varchar[]) 

somehow but I cant find out how..

The best wolud be a plpgsql function for me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:00:19+00:00Added an answer on June 16, 2026 at 7:00 am
    UPDATE test
        SET myarray = myarray || array['fgh','gfdsa']::varchar[][]
        WHERE
            id = 'xyz'
            AND timestp = '2010-01-01 10:10:10'
            AND place = 'nowhere'
            AND not(myarray @> array['fgh','gfdsa']::varchar[][])
        ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Convert date format yyyy-mm-dd => dd-mm-yyyy I am extracting data from MySQL
Possible Duplicate: PHP code to convert a MySQL query to CSV Hi I am
Possible Duplicate: Convert Unixtime to Datetime SQL (Oracle) We have a table of type
Possible Duplicate: Convert MySQL script to MSSQL I have *.sql dump file that generated
Possible Duplicate: MySQL convert timediff output to day, hour, minute, second format I have
Possible Duplicate: How to convert a factor to an integer\numeric without a loss of
Possible Duplicate: How to convert MDB to SQLite in Android I have an MS
Possible Duplicate: How to convert List<Integer> to int[] in Java? I have an ArrayList
Possible Duplicate: How can I convert a string to boolean in JavaScript? I have
Possible Duplicate: Convert a Unix timestamp to time in Javascript I am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.