Update a Table

The update() function is executed on a table from a data source connected to MindsDB. It updates a table on specified columns.

Syntax

Here is the syntax:

/**
 * Update table by condition
 * 
 * @param values  a map representing fields to update
 * @param filters array of filters to filter updated rows, update(values, "column=value", ...)
 */
public void update(Map<String, Object> values, String... filters) 

 /**
 * Update table by condition
 * @param value a Query object representing the data to update
 * @param on array of the columns to update on
 */
public void update(Query value, List<String> on) 

Check out the SQL syntax to better understand how the update() function works.

Database maria  = server.getDatabase("mariadb");
MDBTable table = maria.getTable("another_table");
table.update(Map.of("sqft", "1000"),"sqft=194", "location=great");

Above example uses example_db - house_sales table.

Updated on