Why does switching two column values work by simply reassigning the values in T-SQL?

For example, the following query works just as intended in Microsoft SQL Server (T-SQL).

UPDATE Customer SET ContactName = Customer.City, City = Customer.ContactName; 

I would like to know why the above works. I was expecting Customer.City to remain the same. Why does this happen?

Would appreciate if you could provide some sources so that I can read more on these topics.

Thank you.

How to store the chi-square values in a text file?

I am new to Mathematica. I have a 3×3 textfile 3.txt of numerical values. Each column corresponds to a,b,c respectively. I have a function f(d,e,f). I found the bestfit values for d, e, and f using Chimin, performing a chi-square analysis contrasting with data in my 3×3 textfile 3.txt. The code i created for the same is as follows

<< NumericalCalculus`  SetDirectory["C:/Users/vmsha/Downloads"];  data = ReadList["3.txt", {Number, Number, Number}]  ndata = 3;  Do[a[i] = data[[i, 1]], {i, 1, ndata}]  Do[b[i] = data[[i, 2]], {i, 1, ndata}]  Do[c[i] = data[[i, 3]], {i, 1, ndata}]  Chi[d, e, f] := Sum[((c[i]) - (d*e*f*a[i]))^2/b[i]^2, {i, 1, ndata}]  Chimin = FindMinimum[{Chi[d, e, f], -10 < d < 10, -10 < e < 10, -10 < f < 10}, {d, e, f}]  {0.0177074, {d -> 3.36069, e -> 0.929241, f -> 0.929241}} 

Now, I am interested in getting the whole 3 chi-square values evaluated using chi(d,e,f) in a single text file. Could anybody help?

Turning Mysql values row into columns by form_id and entry_id

I would like to understand how I can turn these rows into columns in MySql

This is how the DB is saved:

id form_id entry_id meta_value
1 7 18 Name
2 7 18 Date
3 7 18 Phone
4 7 18 Email
5 7 18 Status
6 8 19 DOB
7 8 19 Address
8 8 19 Post Code
9 8 19 Country
0 8 19 Notes
11 7 20 Name
12 7 20 Date
13 7 20 Phone
14 7 20 Email
15 7 20 Status
16 8 21 DOB
17 8 21 Address
18 8 21 Post Code
19 8 21 Country
20 8 21 Notes

That is how the table is currently, the idea is combining both form_id (7 & 8) and as a row:

column 1 column 2 column 3 column 4 column 5 column 6 column 7 column 8 column 9 column 10
Name Date Phone Email Status DOB Address Post Code Country Notes
Name Date Phone Email Status DOB Address Post Code Country Notes

I have tried with INNER JOIN and Pivot but I stuck all day on that. If you guys could help would be amazing.

Thanks in advanced

Can a transaction avoid inserting duplicate values in my database?

I have the following table named values:

id serial user_id integer store_id integer identifier VARCHAR(255) created timestamp without time zone DEFAULT NOW() 

But my application has inserted following values:

id user_id store_id identifier created
1 1 1 123cdwe 2021-11-11 13:00:00
1 1 1 Ggrseza 2021-11-11 13:00:00

And that values seem wrong. What I suspect is a replication lag between master and slave alongside with an application termination right just after writing. The application is a web one and I suspect that happens whilst user ferfeshed whilst saving.

Would a transaction could solve the problem or this problem should be tackled at application level?

2D kernel density estimation (SmoothKernelDistribution) with bin width estimation: what are the bin values that Mathematica chooses?

Mathematica has builtin bin estimation including the rules Scott, SheatherJones and Silverman (the default one); they work in both 1D and multiple dimensions. Most of the statistical documentation that I could find of these bin-width rules are for 1D data. Their implementation for 2D or higher dimensions seems not, as far as I know, so robust.

I could not find a Mathematica documentation on how exactly these rules are implemented in any dimensions. For the Silverman case, there is a nice question about it that raises very important subtleties: About Silverman's bandwidth selection in SmoothKernelDistribution .

For 2D data, my first guess was that Mathematica uses the same 1D algorithm, but for each of the axis, thus yielding a diagonal bin matrix. Hence, I extended the code provided in the previous link to 2D as follows:

Clear[data, silvermanBandwidth]; silvermanBandwidth[data_] := silvermanBandwidth[data] = Block[   {m, n},   m = MapThread[Min @ {#1, #2} &,     {       StandardDeviation @ data,       InterquartileRange[data, {{0, 0}, {1, 0}}]/1.349     }   ];   n = Length @ data;   0.9 m/n^(1/5) ]; 

(In the statistical literature I could find different conventions for rounding the real numbers that appear in the above code, I do not know precisely which version Mathematica picks; anyway the problem below is larger than these small rounding changes).

The approach above (and a few variations I tried) is quite close to what Mathematica does in 2D, but it is not identical. Here is an example:

data = RandomReal[1, {100, 2}]; silvermanWMDist = SmoothKernelDistribution @ data; silvermanMyDist = SmoothKernelDistribution[data, silvermanBandwidth @ data, "Gaussian"]; ContourPlot[PDF[silvermanWMDist, {x, y}],   {x, -0.1, 1.1},   {y, -0.1, 1.1} ] ContourPlot[PDF[silvermanMyDist, {x, y}],   {x, -0.1, 1.1},   {y, -0.1, 1.1} ] 

enter image description here

My questions are: how Silverman’s rule is implemented in Mathematica for 2D data? Is there a way to print out Mathematica’s derived bin matrix, either for Silverman or any other rule?

How to determine values of parameters such that an inequality is satisfied?

Given inequality f[x, y]>0 where f[x, y]=1/16 (-1 + x (2 - x + x^3 (-1 + y)^2 y^2)), how can one find the values x (keeping y fixed) such that the inequality is satisfied. And then repeat the same to find y (keeping x fixed)? The answer appears in equation (107) of this article:

$ $ 2(\sqrt{2}-1) \le x \le 1, \qquad \frac{1}{2}\left( 1- \sqrt{ \frac{x^2 +4x – 4}{x^2} } \right) \le y \le \frac{1}{2}\left( 1+\sqrt{ \frac{x^2 +4x – 4}{x^2} } \right)$ $

WordPress Changing input values

I’m trying to write a plugin, I keep my address records in my cart and I want to automatically fill my data with the input values on the payment page, but I couldn’t find it.

Following is my code:

add_filter('woocommerce_checkout_fields', 'custom_override_checkout_fields'); function custom_override_checkout_fields($  fields) { global $  wpdb;  $  list= $  wpdb->get_results("SELECT * From wp_adress");     foreach ($  list as $  value) {         $  firstname = $  value->firstname;         $  lastname = $  value->lastname;         $  phone = $  value->phone;     }     $  fields['billing']['billing_first_name']['value'] = '<?php echo $  value->firstname ?>';     $  fields['shipping']['shipping_first_name']['value'] = '<?php echo $  value->firstname ?>';     $  fields['shipping']['shipping_last_name']['value'] = '<?php echo $  value->lastname ?>';     $  fields['billing']['billing_phone']['value'] = '<?php echo $  value->phone ?> ';     return $  fields; } 

I just want to auto-fill the data in the database on the form checkout page.

Thanks in advance.

Google Analytics GA4 – How to filter data based on Event parameter values

I am very new to GA4 and have been working with Universal analytics for the past 2 years. Now custom events are tracked in my GA4 property along with Event parameters and custom dimensions. But where can I filter an Event using the event parameter data ? Like in Universal Analytics we have an advanced option on the right corner on top of the result table, where we can filter based on "Category/ Action/ Label or dimensions". How can I do the same in GA4 ?

Below is the the filtering options used in UA :

enter image description here

MySQL – Select Records that matches all values

If a table "XYZ" contains two columns as combine primary key, I need to select records that contain both Value1 and Value2 in COLUMN_B ( Result: ID4 )

I tried with "IN" query but it returns the records which contain VALUE1 OR VALUE2 in COLUMN_B (ID1, ID2, ID3, ID4).

Can anybody please help me to write a MySQL query that can do this.

COLUMN_A    COLUMN_B  ID1         Value1 ID2         Value1 ID3         Value2 ID4         Value1 ID4         Value2 ID5         Value3 ID3         Value3 

Thanks in Advance.