{"id":3886,"date":"2023-09-21T14:14:20","date_gmt":"2023-09-21T13:14:20","guid":{"rendered":"https:\/\/help.expertsender.com\/?post_type=es&#038;p=3886"},"modified":"2024-03-19T13:25:10","modified_gmt":"2024-03-19T12:25:10","slug":"updaterow","status":"publish","type":"es","link":"https:\/\/help.expertsender.com\/pl\/emp\/dynamic-content\/data-tables\/updaterow\/","title":{"rendered":"UpdateRow"},"content":{"rendered":"\n<p><code>UpdateRow<\/code> method updates a single row in a custom data table with new data. This is an equivalent of SQL <code>UPDATE<\/code> query.<\/p>\n\n\n\n<p>It is possible to update a single column or multiple columns with one query. Updating multiple rows is disabled, to avoid damaging large amounts of data by mistake.<\/p>\n\n\n\n<p>This method may be useful if you need to mark in your custom data that an email was sent to particular subscriber. You may want to save sending date, or generate emails with single-use offers (such as unique coupons), using both <code>GetRows<\/code> and <code>UpdateRow<\/code> methods.<\/p>\n\n\n\n<p><strong>1. Method signature<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:7.703125px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"UpdateRow(table, updates, filters, filterOperator)\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #82AAFF\">UpdateRow<\/span><span style=\"color: #BABED8\">(table<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> updates<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> filters<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> filterOperator)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Parameter definition:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Name<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>table<\/td><td>string<\/td><td>Required. Table name.<\/td><\/tr><tr><td>updates<\/td><td>array of Update objects<\/td><td>Required. Array of objects describing columns that will be updated with new values (equivalent of SET part of SQL UPDATE query).<\/td><\/tr><tr><td>filters<\/td><td>array of Filter objects<\/td><td>Optional. Array of objects defining elements of&nbsp;<code>WHERE<\/code>&nbsp;phrase of&nbsp;<code>UPDATE<\/code>&nbsp;query. Use this parameter, to restrict updating row only if it matches your criteria. If null, no criteria will be applied. If several filters are defined, by default, updated row will match all of them (equivalent to logical&nbsp;<code>AND<\/code>&nbsp;).&nbsp;<br>Default behavior can be overridden using&nbsp;&nbsp;<code>filterOperator<\/code>&nbsp;&nbsp;parameter.<\/td><\/tr><tr><td>filterOperator<\/td><td>enumeration<\/td><td>Optional. Logical operator used for filters. Can be one of the following:AND (filter1 AND filter2 AND filter3&#8230;) &#8211; this is the default valueOR (filter1 OR filter2 OR filter3&#8230;)ANDNOT (NOT filter1 AND NOT filter2 AND NOT filter3&#8230;)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><code>Update<\/code> object parameter definition<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Name<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>name<\/td><td>string<\/td><td>Column name.<\/td><\/tr><tr><td>value<\/td><td>object<\/td><td>New column value. Value type depends on column type, e.g. when filtering by number column, integer value should be supplied, string for text columns etc. Simple type conversion is also supported, e.g. string &#8220;123&#8221; representing correct integer value 123 will be accepted. This also works for dates, floating point numbers etc.<\/td><\/tr><tr><td>type<\/td><td>enumeration<\/td><td>Update type. Optional. Valid values are:UpdateType.Update (Value substitution, e.g. &#8220;x = value&#8221;. This is the default value.)UpdateType.Increment (Value incrementation, e.g. &#8220;x = x + value&#8221;.)NOTE: Increments are not suitable for all column types. Supported types are Number and Double. String and Text types will work as well (string concatenation will be performed).<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><code>Filter<\/code> object parameter definition<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Name<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>Name<\/td><td>string<\/td><td>Column name<\/td><\/tr><tr><td>Modifier<\/td><td>enumeration<\/td><td>Operation modifier. Can be one of the following:EQ (equals, &#8220;=&#8221;)GT (greater than, &#8220;&gt;&#8221;)LT (lower than, &#8220;&lt;&#8220;)LIKE (SQL&nbsp;<code>LIKE<\/code>&nbsp;operator)<\/td><\/tr><tr><td>Value<\/td><td>object<\/td><td>Column value. Value type depends on column type, e.g. when filtering by number column, integer value should be supplied, string for text columns etc. Simple type conversion is also supported, e.g. string &#8220;123&#8221; representing correct integer value 123 will be accepted. This also works for dates, floating point numbers etc.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Note: Filters work the same way as in <code>GetRows<\/code> method. See<a href=\"https:\/\/sites.google.com\/expertsender.com\/dynamic-content-documentation\/data-tables\/getrows\"> GetRows documentation<\/a> for more details and examples.<\/p>\n\n\n\n<p><strong>2. Usage and examples<\/strong><\/p>\n\n\n\n<p>You can call UpdateRow method using curly braces syntax. You may put in anywhere in the email template code since its output is empty string.<\/p>\n\n\n\n<p><br>Example 1 &#8211; the most simple call<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:7.703125px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"${UpdateRow('MyTable', new [] {new Update('MyColumn', 456)})}\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">UpdateRow<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">MyTable<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #F07178\"> [] <\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #F07178\">new Update<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">MyColumn<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> 456<\/span><span style=\"color: #89DDFF\">)}<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Equivalent SQL query:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:7.703125px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"UPDATE TOP(1) MyTable SET MyColumn = 456\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">UPDATE <\/span><span style=\"color: #82AAFF\">TOP<\/span><span style=\"color: #BABED8\">(<\/span><span style=\"color: #F78C6C\">1<\/span><span style=\"color: #BABED8\">) MyTable SET MyColumn <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">456<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This however has limited use, since in most cases, you will want to update a specific row (and not first found). Following examples show how to use filters to achieve this.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Example 2 &#8211; updating single column in a row matching specified criteria<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:7.703125px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"${UpdateRow('MyTable', new [] {new Update('MyColumn', 456)}, new [] {new Filter('CustomerId', EQ, 123)})}\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">UpdateRow<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">MyTable<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #F07178\"> [] <\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #F07178\">new Update<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">MyColumn<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> 456<\/span><span style=\"color: #89DDFF\">)},<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #F07178\"> [] <\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #F07178\">new Filter<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">CustomerId<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #BABED8; font-style: italic\">EQ<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> 123<\/span><span style=\"color: #89DDFF\">)}<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Equivalent SQL query:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:7.703125px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"UPDATE TOP(1) MyTable SET MyColumn = 456 WHERE CustomerId = 123\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">UPDATE <\/span><span style=\"color: #82AAFF\">TOP<\/span><span style=\"color: #BABED8\">(<\/span><span style=\"color: #F78C6C\">1<\/span><span style=\"color: #BABED8\">) MyTable SET MyColumn <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">456<\/span><span style=\"color: #BABED8\"> WHERE CustomerId <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">123<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Example 3 &#8211; updating multiple columns<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:7.703125px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"${UpdateRow('MyTable', new [] {new Update('MyColumn', 456), new Update('ProductName', 'Snowboard')}, new [] {new Filter('CustomerId', EQ, 123)})}\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">UpdateRow<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">MyTable<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #F07178\"> [] <\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #F07178\">new Update<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">MyColumn<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> 456<\/span><span style=\"color: #89DDFF\">),<\/span><span style=\"color: #F07178\"> new Update<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">ProductName<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">Snowboard<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">)},<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #F07178\"> [] <\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #F07178\">new Filter<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">CustomerId<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #BABED8; font-style: italic\">EQ<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> 123<\/span><span style=\"color: #89DDFF\">)}<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Equivalent SQL query:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:7.703125px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"UPDATE TOP(1) MyTable SET MyColumn = 456, ProductName = 'Snowboard' WHERE CustomerId = 123\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">UPDATE <\/span><span style=\"color: #82AAFF\">TOP<\/span><span style=\"color: #BABED8\">(<\/span><span style=\"color: #F78C6C\">1<\/span><span style=\"color: #BABED8\">) MyTable SET MyColumn <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">456<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> ProductName <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">Snowboard<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #BABED8\"> WHERE CustomerId <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">123<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>It is of course possible to specify multiple filters &#8211; the equivalent of AND logical operator (or a different operator specified using <code>filterOperator<\/code> parameter). It is also possible (and in most cases necessary) to match updated rows with subscriber properties, email etc.<\/p>\n\n\n\n<p>See<a href=\"https:\/\/sites.google.com\/expertsender.com\/dynamic-content-documentation\/data-tables\/getrows\"> GetRows method examples<\/a> for more information.<\/p>\n\n\n\n<p>Example 4 &#8211; incrementing column value<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:7.703125px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"${UpdateRow('MyTable', new [] {new Update('MyCounterColumn', 5, UpdateType.Increment)}, new [] {new Filter('CustomerId', EQ, 123)})}\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">UpdateRow<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">MyTable<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #F07178\"> [] <\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #F07178\">new Update<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">MyCounterColumn<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> 5<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> UpdateType.Increment<\/span><span style=\"color: #89DDFF\">)},<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #F07178\"> [] <\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #F07178\">new Filter<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">CustomerId<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #BABED8; font-style: italic\">EQ<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> 123<\/span><span style=\"color: #89DDFF\">)}<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Equivalent SQL query:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:7.703125px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"UPDATE TOP(1) MyTable SET MyCounterColumn = MyCounterColumn + 5 WHERE CustomerId = 123\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">UPDATE <\/span><span style=\"color: #82AAFF\">TOP<\/span><span style=\"color: #BABED8\">(<\/span><span style=\"color: #F78C6C\">1<\/span><span style=\"color: #BABED8\">) MyTable SET MyCounterColumn <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> MyCounterColumn <\/span><span style=\"color: #89DDFF\">+<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">5<\/span><span style=\"color: #BABED8\"> WHERE CustomerId <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">123<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>It is possible to perform multiple increments in a single call or mix regular updates and increments.<\/p>\n\n\n\n<p>Example 5 &#8211; real-life scenario, sending emails with single-use coupons<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:7.703125px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"&lt;!-- get coupon for customer and store in a variable --&gt;\n&lt;var rows=&quot;GetRows('Coupons', 1, null, new [] {new Filter('CustomerId', EQ, SubscriberProperty('customer_id')), new Filter('IsUsed', EQ, false)})&quot;\/&gt;\n&lt;!-- display coupon code in email --&gt;\n&lt;p&gt;Hello! Here's your coupon: ${rows[0]['CouponCode']}&lt;\/p&gt;\n&lt;!-- mark coupon as used and save the date it was used on --&gt;\n${UpdateRow('Coupons', new [] {new Update('IsUsed', true), new Update('UsedOn', System.DateTime.UtcNow)}, new [] {new Filter('CouponId', EQ, rows[0]['CouponId'])})}\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #89DDFF\">&lt;!--<\/span><span style=\"color: #BABED8\"> get coupon for customer and store <\/span><span style=\"color: #89DDFF\">in<\/span><span style=\"color: #BABED8\"> a variable <\/span><span style=\"color: #89DDFF\">--&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #F07178\">var<\/span><span style=\"color: #89DDFF\"> <\/span><span style=\"color: #C792EA\">rows<\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">GetRows(&#39;Coupons&#39;, 1, null, new [] {new Filter(&#39;CustomerId&#39;, EQ, SubscriberProperty(&#39;customer_id&#39;)), new Filter(&#39;IsUsed&#39;, EQ, false)})<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #89DDFF\">\/&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">&lt;!--<\/span><span style=\"color: #BABED8\"> display coupon code <\/span><span style=\"color: #89DDFF\">in<\/span><span style=\"color: #BABED8\"> email <\/span><span style=\"color: #89DDFF\">--&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #F07178\">p<\/span><span style=\"color: #89DDFF\">&gt;<\/span><span style=\"color: #BABED8\">Hello! Here&#39;s your coupon: $<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #BABED8\">rows[<\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #BABED8\">][<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">CouponCode<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #BABED8\">]<\/span><span style=\"color: #89DDFF\">}&lt;\/<\/span><span style=\"color: #F07178\">p<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">&lt;!--<\/span><span style=\"color: #BABED8\"> mark coupon <\/span><span style=\"color: #89DDFF; font-style: italic\">as<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #FFCB6B\">used<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #FFCB6B\">and<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #FFCB6B\">save<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #FFCB6B\">the<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #FFCB6B\">date<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #FFCB6B\">it<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #FFCB6B\">was<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #FFCB6B\">used<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #FFCB6B\">on<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">--&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">UpdateRow<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">Coupons<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #F07178\"> [] <\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #F07178\">new Update<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">IsUsed<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #BABED8; font-style: italic\">true<\/span><span style=\"color: #89DDFF\">),<\/span><span style=\"color: #F07178\"> new Update<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">UsedOn<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> System.DateTime.UtcNow<\/span><span style=\"color: #89DDFF\">)},<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #F07178\"> [] <\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #F07178\">new Filter<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">CouponId<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #BABED8; font-style: italic\">EQ<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #BABED8; font-style: italic\">rows<\/span><span style=\"color: #89DDFF\">[<\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #89DDFF\">][<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">CouponId<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">])}<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">}<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"author":6,"featured_media":0,"parent":3874,"menu_order":216,"template":"","format":"standard","emp-category":[],"class_list":["post-3886","es","type-es","status-publish","format-standard","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/es\/3886","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/es"}],"about":[{"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/types\/es"}],"author":[{"embeddable":true,"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/users\/6"}],"version-history":[{"count":2,"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/es\/3886\/revisions"}],"predecessor-version":[{"id":8869,"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/es\/3886\/revisions\/8869"}],"up":[{"embeddable":true,"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/es\/3874"}],"wp:attachment":[{"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/media?parent=3886"}],"wp:term":[{"taxonomy":"emp-category","embeddable":true,"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/emp-category?post=3886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}