I got value of user meta key like a:1:{s:8:"investor";b:1;} - sql

I have got like this meta key a:1:{s:8:"investor";b:1;} but i want get only one string like "investor" in switch case condition.

Related

How to get the multiple key value pairs from jsonb object in postgresql?

I have column response_payload in table response as below
{"studentName":"Karate","studentStream":"API Testing", "studentAge":18}
Now I need to get the new json object based on my keys. For example, if my keys are studentName and studentStream I must get
{"studentName":"Karate","studentStream":"API Testing"}
In case if I provide invalid key, it should not bring anything related to invalid key.
I have tried json_build_object built-in function in postgresql, it is bringing invalid key and value as below
select json_build_object('invalidKey', payload -> 'invalidValue')
from response
O/P:- {"invalidKey":"null"}
I want output when invalid key and value is provided, it should not bring anything as below
O/p:- {}
You can use jsonb_strip_nulls
select
jsonb_strip_nulls(jsonb_build_object('invalidKey', payload -> 'invalidValue'))
from response

How to get keys from the value in redis

I have checked following, but didn't work.
https://redis.io/commands/keys
KEYS Room:*
1) "Room:120"
2) "Room:121"
3) "Room:122"
Following is the redis key/values (HMSET)
Room:120 [SocketId:mOQDJusPjDTBN5L-AAAC,TimeStamp:10-10-2017 12:10:00 AM]
Room:121 ....
Room:122 ....
...
Need to search as Room:* SocketId:mOQDJusPjDTBN5L-AAAC
How can I search for SocketId in the collection ?
Need to search with:
mOQDJusPjDTBN5L-AAAC
The question is not so clear
as u mentioned hmset i am assuming that you are using hashes to store your data.
As per your data,
'room120' should be the key, 'socketId' should be the field and 'mOQDJusPjDTBN5L-AAAC' should be the value.
so in order to search for socketId you can use hscan,where hscan iterates through the field of a particular key.https://redis.io/commands/scan
in case if you are just using key/value storage i.e
'socketId' being the key ,'mOQDJusPjDTBN5L-AAAC' being the value.
here u can just use the command Keys *socket*to search for the key socketId

GET url with nested element inside query string

Using Postman, I am forming a GET request query to my P21 database middleware to retrieve items with a specific value in a UserDefinedField.
I am able to query things on the top level of the item data, such as ItemID and ItemDesc like so:
http://[server]:[port]/api/inventory/parts?$query=ItemDesc eq 'CONTROL VALVE'
However, the values I would like to use in my query string are nested inside the UserDefinedFeilds element. I am specifically looking for items with:
http://[server]:[port]/api/inventory/parts?$query=UserDefinedFeilds/OnEbay eq 'Y'
But this is not the correct way to form this query string. Can anyone please explain how to specify a nested element inside a query string like this? Thanks.
In this situation, using P21 API, it is unnecessary to specify the parent field 'UserDefinedFields'. The actual ID of the column I was looking for was actually 'on_ebay', so I was able to query this user defined field simply:
http://[server]:[port]/api/inventory/parts?$query=on_ebay eq 'Y'

How to get objects from worklight JSONStore where value of specific attribute attribute is null or empty

How can I get all the objects from JSONSTore where the value of specified attribute is null.
I have tried to specify the value of attribute as empty or null but not able to get the result.
I have to implement the below SQL query in IBM Worklight to get data from JSONStore.
select * from employee where age IS NULL
Make sure you have something like this in your search fields: {value: 'string'}.
Then add data like this: WL.JSONStore.get('collection').add({value: 'NULL'}).
Then search for it like this: WL.JSONStore.get('collection').find({value: 'NULL'}).
It is not currently possible to search for things that are not string, integer, number or boolean. Notice that 'NULL' is a string in my examples above.
Feature requests here.

Take email value from table in query

I'm trying to replace all avatars with an avatar generator.
The avatars get generated by putting your email address in the URL.
(I've tried searching but resulted in no solution. That may be because I don't really know what to exactly search for. I hope you can help me out by either linking me an existing thread or simply giving an answer.)
My current table has 2 columns, avatars and email
I want to replace all avatars hello.jpg with //avatar.com/emailadress.png
How can I put the users email value in the replacement query?
I'm using MySQL as DMBS.
This is my current query.
UPDATE members SET avatar = REPLACE(avatar, 'hello.jpg', '//avatar.com/%.png')
% Would be the value of the email adress.
Thank you!
You can just simply concatenate in the value of the email column to the second parameter of REPLACE:
UPDATE members SET avatar = REPLACE(avatar, 'hello.jpg', CONCAT('//avatar.com/', email, '.png'))
WHERE avatar LIKE '%hello.jpg%';
If you want to test it before updating the column. Have a look at the output of this:
SELECT REPLACE(avatar, 'hello.jpg', CONCAT('//avatar.com/', email, '.png'))
from members
WHERE avatar LIKE '%hello.jpg%';