Re: UPDATE with multiple WHERE conditions

2024-06-13 Thread Alvaro Herrera
On 2024-Jun-12, David G. Johnston wrote: > On Wed, Jun 12, 2024 at 2:28 PM Rich Shepard > wrote: > > > I have a table with 3492 rows. I want to update a boolean column from > > 'false' to 'true' for 295 rows based on the value of another column. > > I'll often just use a spreadsheet to build th

Re: UPDATE with multiple WHERE conditions

2024-06-12 Thread Rich Shepard
On Wed, 12 Jun 2024, Rob Sargent wrote: Add "begin;" to that and try it.  If you don't get exactly UPDATE 295 reported, then "rollback;"; Got it, thanks. Rich

Re: UPDATE with multiple WHERE conditions

2024-06-12 Thread Rich Shepard
On Wed, 12 Jun 2024, Ron Johnson wrote: A plain UPDATE might work. UPDATE to_be_updated a SET bool_col = true FROM other_table b WHERE a.pk = b.pk AND b.field3 = mumble; (You can join them, right?) Thanks, Ron. Rich

Re: UPDATE with multiple WHERE conditions

2024-06-12 Thread Rich Shepard
On Wed, 12 Jun 2024, David G. Johnston wrote: I'll often just use a spreadsheet to build the 295 update commands and copy-paste them into psql or whatnot. David, I'll create and use a temporary table. Thanks, Rich

Re: UPDATE with multiple WHERE conditions

2024-06-12 Thread David G. Johnston
On Wed, Jun 12, 2024 at 2:28 PM Rich Shepard wrote: > I have a table with 3492 rows. I want to update a boolean column from > 'false' to 'true' for 295 rows based on the value of another column. > > Is there a way to access a file with those condition values? > I'll often just use a spreadsheet

Re: UPDATE with multiple WHERE conditions

2024-06-12 Thread Rob Sargent
On 6/12/24 15:48, Ron Johnson wrote: On Wed, Jun 12, 2024 at 5:28 PM Rich Shepard wrote: I have a table with 3492 rows. I want to update a boolean column from 'false' to 'true' for 295 rows based on the value of another column. Is there a way to access a file with those conditio

Re: UPDATE with multiple WHERE conditions

2024-06-12 Thread Ron Johnson
On Wed, Jun 12, 2024 at 5:28 PM Rich Shepard wrote: > I have a table with 3492 rows. I want to update a boolean column from > 'false' to 'true' for 295 rows based on the value of another column. > > Is there a way to access a file with those condition values? If not, should > I create a temporary

Re: UPDATE with multiple WHERE conditions

2024-06-12 Thread Rich Shepard
On Thu, 13 Jun 2024, Muhammad Salahuddin Manzoor wrote: You can use Temporary table. You could create a temporary table with one column containing the condition values and then use it to update your main table. This approach can be more flexible and cleaner than writing a script with multiple up

Re: UPDATE with multiple WHERE conditions

2024-06-12 Thread Muhammad Salahuddin Manzoor
Greetings, You can use Temporary table. You could create a temporary table with one column containing the condition values and then use it to update your main table. This approach can be more flexible and cleaner than writing a script with multiple update statements. -- Create a temporary table w

UPDATE with multiple WHERE conditions

2024-06-12 Thread Rich Shepard
I have a table with 3492 rows. I want to update a boolean column from 'false' to 'true' for 295 rows based on the value of another column. Is there a way to access a file with those condition values? If not, should I create a temporary table with one column containing those values, or do I write