display filled field as empty field mysql view - mysql

How can I display as view a filled field as empty field in mysql?
It's about the field klanten.KlantEmail
thanks in advance
SELECT
klanten.KlantId,
klanten.KlantRelid,
klanten.KlantU4relid,
klanten.KlantZoeknaam,
klanten.KlantNaam,
klanten.KlantStraat,
klanten.KlantHuisnummer,
klanten.KlantAdres,
klanten.KlantPostcode,
klanten.KlantPlaats,
klanten.KlantPostbus,
klanten.KlantEmail
FROM
klanten

No you would do this, assuming you want to output the column but have it as a empty string regardless or what is really in the column
SELECT
klanten.KlantId,
klanten.KlantRelid,
klanten.KlantU4relid,
klanten.KlantZoeknaam,
klanten.KlantNaam,
klanten.KlantStraat,
klanten.KlantHuisnummer,
klanten.KlantAdres,
klanten.KlantPostcode,
klanten.KlantPlaats,
klanten.KlantPostbus,
"" as klanten.KlantEmail
FROM
klanten

Related

Values from xml data field in mysql

i would like to know if there is a query to select values from all of my xml data fields. There are around 1k rows which has xml data. All of them has almost the same data structure. With extract value i was able to extract one data field but at the point where more than one row is part of my subquery it breaks.
Here is an example xml data inside my db:
<EDLXML version="1.0.0" type="variable">
<properties id="template_variables">
<deliveredDuration>4444</deliveredDuration>
<deliveredNum>1</deliveredNum>
<comment/>
<projectname>cdfkusen</projectname>
<name>kral_schalke_trenink</name>
<order_id>372846</order_id>
<cutlistId>2763_ID</cutlistId>
<bcutlistId>51ddgf7a6-1268-1gdfged-95e6-5254000e8e1a</bcutlistId>
<num>1</num>
<duration>177760</duration>
<quotaRelevantDuration>0</quotaRelevantDuration>
<organisationUid>OrgName</organisationUid>
<organisationQuota>333221233</organisationQuota>
<organisationUsedQuota>123</organisationUsedQuota>
<organisationContingentIrrelevantQuotaUsed>54</organisationContingentIrrelevantQuotaUsed>
<userDbId>7xxxx84-eb9b-11fdsb-9ddd1-52cccccde1a</userDbId>
<userId>xxxx</userId>
<userRights>RH_DBC</userRights>
<firstName>DThom</firstName>
<lastName>Test</lastName>
<userMail>xxx#ccc.cz</userMail>
<language>English</language>
<orderTimestamp>1659448080</orderTimestamp>
<stitching>false</stitching>
<transcode>NO</transcode>
<destination>Standard</destination>
<collaboration>private</collaboration>
<premiumUser>false</premiumUser>
<priority>normal</priority>
<userMail2>xxx#ccc.cz</userMail2>
<cutlistItems>
<cutListId>125124_KFC</cutListId>
<cutListItemId cutlistItemDeliveryStatus="&#10004" cutlistItemDStatusMessage="delivered">112799</cutListItemId>
<bmarkerId>8f16ff80-1269-11ed-95e6-5254000e8e1a</bmarkerId>
<videoId>2912799</videoId>
<counter>1</counter>
<frameInSpecified>true</frameInSpecified>
<frameIn>15638</frameIn>
<frameOutSpecified>true</frameOutSpecified>
<frameOut>20082</frameOut>
<tcIn>00:10:25:13</tcIn>
<tcOut>00:13:23:07</tcOut>
<duration>177760</duration>
<BroadcastDate>2021-07-24</BroadcastDate>
<eventDate>2021-07-24</eventDate>
<resolutionFacet>HD</resolutionFacet>
<provider>DBC</provider>
<technicalrightholders>RH_DBC</technicalrightholders>
<rights>DBC</rights>
<materialType>DP</materialType>
<targetFilename>kral_schalke_trenink</targetFilename>
</cutlistItems>
</properties>
</EDLXML>
I got the right value from query if i do:
SELECT ExtractValue((SELECT job_xml from cutlist where job_xml is not null LIMIT 1), '//deliveredNum');
But when i change the limit amount i get back: Subquery return more than one row.
extractvalue expects two string arguments. When your subquery returns more than one row, you are not simply passing a string as the first argument (you are passing a set of results).
Instead of calling extractvalue once for your entire query, call it once for every row, like:
SELECT ExtractValue(job_xml, '//deliveredNum')
FROM cutlist
WHERE job_xml IS NOT NULL

Search on array of strings column in MYSQL

I have a column name "multiselect_value" in which i am storing data as array of strings. Here is a sample
multiselect_value
["Books","Hockey","Movies"]
["Cricket","Books","Movies"]
Now i have a input value like ["Hockey","Books"] and i want to get those records in which this value exist in "multiselect_value" column
Here is what i have tried
SELECT user_id,multiselect_value
FROM user_custom_field_data
WHERE FIND_IN_SET("Books",multiselect_value) > 0;

regex_replace function skips anything coming after a NULL value

In my hive table "ticket_full" I have a json type column named "service_id" that I would like to extract in 3 columns, which is like this
[{"position":"1","typeid":"ROUTNAME","value":"PWAW13197"},{"position":"2","typeid":"CDCNAME","value":null},{"position":"3","typeid":"SVCNAME","value":"Business"},{"position":"4","typeid":"USID","value":"FI021MLQE4"}]
[{"position":"1","typeid":"ROUTNAME","value":"KHLA30076"},{"position":"2","typeid":"CDCNAME","value":"eff-e-rjh-sw-cs2"},{"position":"3","typeid":"SVCNAME","value":"Managed LAN"},{"position":"4","typeid":"USID","value":"SA00BNGH0E"}]
[{"position":"1","typeid":"NUMLIAPTT","value":"0492212984"},{"position":"2","typeid":null,"value":null},{"position":"3","typeid":null,"value":null},{"position":"4","typeid":null,"value":null}]
I used the code below:
SELECT get_json_object(single_json_table.identifiant_produit, '$.position') AS position,
get_json_object(single_json_table.identifiant_produit, '$.typeid') AS typeid,
get_json_object(single_json_table.identifiant_produit, '$.value') AS value
FROM
(SELECT explode(split(regexp_replace(substr(serviceid, 2, length(serviceid)-2),
'"},\\{"', '"},,,,{"'), ',,,,') ) as identifiant_produit
FROM ticket_full) single_json_table
it works but every time there is a value at NULL, it ignores what follows and goes to the next field:
example:
Does anyone know how to fix this please ?
It is because null has no double-quotes and you are replacing this '"},\\{"' with this '"},,,,{"'
Try to remove double-quote before } in the regex pattern and replacement string accordingly, then it will work with quoted values and nulls also:
split(regexp_replace(substr(serviceid, 2, length(serviceid)-2),
'},\\{"', '},,,,{"'), ',,,,')

SSRS - Hide a row in group based on value

I have the table below in SSRS, i would like to hide a row contains the value "MT" (which in a group "Date").
This is the result without expression on row visibility:
And this is the result with the expression on the Row visibility:
=IIF(Fields!Message_type.Value = "MT", False, True)
It deletes all the table because of the group i guess, i want to keep the column "Date" and hide only the row with "MT" value.
Could somebody tell me how can i do it please.
Thanks in advance.

How to filter a name from a sentence in database?

I want to query string from a field from my database. For example: Field "Address", value "Toul Kork District, Phnom Penh". Want I want to get is only "Phnom Penh". I know that my sql is not allow to select only this string from the field. So, what is the good way to do that?
This may help you :
SELECT SUBSTR(Address,
LOCATE(Value,Address),
LENGTH(Address) - LENGTH(Value));
POSITION function is synonim for LOCATE. You can use POSITION function as well :
SELECT SUBSTR(Address,
LOCATE(Value IN Address),
LENGTH(Address) - LENGTH(Value));
In static variable it's looks like :
SELECT SUBSTR('Toul Kork District,Phnom Penh',
LOCATE('Phnom Penh','Toul Kork District,Phnom Penh'),
LENGTH('Toul Kork District,Phnom Penh') - LENGTH('Phnom Penh'));
Result : Phnom Penh