Tag Archives: update

Remove line breaks and spaces from Table field

Had an issue with a huge table of email address not really compliant. Some had trailing/ending spaces, others even line breaks. To fix the line breaks, this worked:   update emails_table set email = replace(email, ‘\n’, ”)   To remove trailing/ending spaces, i used this:   update emails_table set email=trim(email)   Go and be happy.

update with join – another version – postgreSQL

This time its a second version of what i already posted, but might help some poor soul out there (and me, since i keep forgetting stuff). UPDATE “Patrimonio” SET x=st_x(“Morada”.geometry), y=st_y(“Morada”.geometry) FROM “Morada” WHERE “Patrimonio”.morada_id = “Morada”.”id” This example is specifically for PostgreSQL, acting on a geometry point column, but can easily, or almost directly,… Read More »

update table with values from other table

I ran into a problem where i had to update two values on a table. One was fixed, but the other depended on a value stored on a second table. This is how its done. TableA id_cli   test_cut 1          15 2          56 TableB id    num_of        job    test_cut    id_client 1     20090464    34      0               2 2    … Read More »

update table with join condition from different table

If we want to make an update to a table, but have to condition that update with values from a second one, we do something like this: TABLE_1 id_t1 name fee 1 john 100 2 rita 100 3 peter 100 TABLE_2 id_t2 id_t1 type 1 1 single 2 2 single 3 3 married If we… Read More »