{"id":1529,"date":"2022-11-19T00:01:08","date_gmt":"2022-11-19T00:01:08","guid":{"rendered":"\/blog\/?p=1529"},"modified":"2022-11-19T00:01:08","modified_gmt":"2022-11-19T00:01:08","slug":"mysql-generated-columns-same-table","status":"publish","type":"post","link":"\/blog\/index.php\/mysql-generated-columns-same-table\/","title":{"rendered":"mysql generated columns (same table)"},"content":{"rendered":"\n<p>This is to add a column in a table with calculated values from the same table.<\/p>\n\n\n\n<p><code>ALTER TABLE pedidos add column impuesto float generated always as (subtotal*.16) VIRTUAL;<\/code><\/p>\n\n\n\n<p><code>ALTER TABLE pedidos add column total float generated always as (subtotal*1.16) VIRTUAL;<\/code><\/p>\n\n\n\n<p><code>ALTER TABLE pedidos add column flete float generated always as (case when total &lt; 6000 then 1000 else 0 end) virtual<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is to add a column in a table with calculated values from the same table. ALTER TABLE pedidos add column impuesto float generated always as (subtotal*.16) VIRTUAL; ALTER TABLE pedidos add column total float generated always as (subtotal*1.16) VIRTUAL; ALTER TABLE pedidos add column flete float generated always as (case when total &lt; 6000 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1529","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1529"}],"version-history":[{"count":1,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1529\/revisions"}],"predecessor-version":[{"id":1530,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1529\/revisions\/1530"}],"wp:attachment":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1529"},{"taxonomy":"post_tag","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}