Multiple same kind of column concatenation in another column of same table in mysql - mysql

I have one table "Mytable" and in this i have multiple columns and now in this columns i have 100 columns with same name like "type1", "type2"..,"type99" and i am importing this value from csv. so now what i want to do is i want to combined all this column value in one single column in json format.
Can any one suggest me how can i achieve?

You can create the json object as:
select json_object('type1', type1, 'type2', type2, . . . )
Alternatively, you might want an array.
You can then insert this into a new table.

Related

replace multiple values in the same column as transformation with SSiS

I have a data set with country column , the countries with the there codes but i need to replace this codes with the actual names , I am trying the derived column transform but it
only accept on values to replace it
any ideas ?
[1] https://i.stack.imgur.com/imv2m.png]

How to loop through a list of tables by their corresponding name?

I want to loop over a list of tables that I get using the following query.
select table_name from information_schema.tables
where (lower(table_name) like '%ap_form_%') && substring(table_name, 9, char_length(table_name) - 1) in (
select form_id
from ap_form_elements elements
where elements.element_type = "email"
);
This query gets all the table names of the tables that have got an email field. I need to use this list to access the actual tables, and for each table append their date_created field to a temporal table variable.
How can I access these tables? I know their name but I don't know how to get the actual tables and loop through them.

MS-Access: Replace values in column based on mapping list

I got a column with 27 thousand entries. I want to replace all occurences of "a" with "a_new", all occurences of "b" with "b_whatever". And so on. I got more than 1200 of these mappings. Can I somehow put my mappings into a list and feed it to MS-Access so that it replaces the values in a specific column?
Create new table with mapping - [OldValue] and [NewValue] columns, then join this table with your existing table by [OldValue] column and update by value from '[NewValue]`

Extract XML data from Hive Table and Parse the data

I want to extract particular column values from a hive table. That column has XML data. How to parse through XML data and extract name and values from that particular XML column. Also I want to insert the extracted data into another Hive table.
Option 1 : LanguageManual XPathUDF
Example :
select xpath ('<a><b id="1"><c/></b><b id="2"><c/></b></a>','/descendant::c/ancestor::b/#id') from t1 limit 1 ;
[1","2]
Option2 : Another way of achieving this is Hive-XML-SerDe
In both option you need to have Xpath expression knowledge.
If you want to insert extracted data in to another table then use create table as select xxx from xxxxx (Create Table As Select (CTAS))

MySQL alter All Columns In table

I have 4 tables.There are columns in each table which have identical names.
Each table has for instance, "id" column.
These make for terrible arrays in PHP.
The solution to my trouble is to prepend column names with the name of the table.
Is there a MySQL statement which would add "name" to the start of every column in name the table?
So that the id field in people table would become peopleid, for instance.
When you do a select, you can give the column an alias.
SELECT id AS 'PeopleID' FROM People