I have SQL table as UserInfo with columns [id, username, details]. I need to update a part of a string from the column details.
For example. details column will look like,
{"username":"user.sample#nomail.org","rollno":45,"gender":"male"}
P.S: In actual DB this column is really long with more details, for example, I quoted above few details.
Condition is that the username value in the details column should be the same as the value in the username column.
I have n number of records mismatching in the DB, meaning username column value is different from username information in the details column.
Ex
id - username - details
23 - new-user#nomail.org - {"username":"user.sample#nomail.org","rollno":45,"gender":"male"}
Hence I am trying to replace the "username": "value" in details column with the username column value
EX - Expected should be like,
id - username - details
23 - new-user#nomail.org - {"username":"new-user#nomail.org","rollno":45,"gender":"male"}
For updating UserInfo, I am trying like
update UserInfo
set details = replace(details, \Regex\ ,"username:"+ username)
where id not in (select id from UserInfo where details like '%'+userid+'%' )
I need to regex pattern matching, ["username":"mail-id"], so that I can able to replace that particular string in that details column.
Any idea/suggestion for the regex pattern would be helpful
Related
Suppose I have given such a table in sql
According to Gmail (which I have given in advance) I want to get the Username value.
For example, if "Gmail" would be "Gela1#gmail.com" I should get string - "Gela gela".
if "Gmail" would be "mamuka#gmail.com" I should get string - "Mamuka snaia".
How to do this?
You can easily make an SQL query like:
SELECT Username from tableName where Gmail = 'Gela1#gmail.com'
Replace tableName with your table name.
https://www.w3schools.com/sql/sql_select.asp
I have a field in my BQ table which is of type string and I need to select some characters in between them.
What I have:
student_details is the table, and details is the only field in the table and is of type STRING.
details
name:rishi;id=32a01a-2tf5-433a-7117-12323adfr2;dept:maths
name:vineeth;id=83faf-34fa-9912-afd-dsfeffef13fd;dept:science
I need only id in a separate field.
what I want:
(Basically I want characters after id= and before ;dept)
details id
name:rishi;id=32a01a-2tf5-433a-7117-12323adfr2;dept:maths 32a01a-2tf5-433a-7117-12323adfr2
name:vineeth;id=83faf-34fa-9912-afd-dsfeffef13fd;dept:science 83faf-34fa-9912-afd-dsfeffef13fd
Could anyone please help me on this.
You can use regexp_extract():
select regexp_extract(details, ';id=([^;]+);') as id
I have a table with 3 columns: username, password and ID.Every password and username have a specific ID. Table name is "Account" for example.
I want to update a password with a specific ID. I have tried:
UPDATE Account SET password = "newPassword"
where id = 1
However, it does not work. It will complain that "newPassword" is not a valid column name. I try my queries in SQL management studio.
Use single quotes for string literals in MS SQL Server:
UPDATE Account
SET password = 'newPassword'
WHERE id = 1;
Double quotes in SQL are generally reserved for database objects, such as table and column names (sometimes called identifiers). Your current update is attempting to assign the password column to a column named newPassword. This column doesn't exist, hence you are getting an error.
I'm an Oracle newbie.
I have a column in my table that contains a pipe(|)-separated string such as this:
uguyguyguyguyguy|0737494110|noreply#xxyyxx.se|E:\PROD_ActionMarketer\Program\Apsis\ApsisREST.exe|E:\PROD_ActionMarketer\Temp\TempApsisAdmin.skv|SENDEMAIL|"LIST=Daily SMS SPL"|1015832
As you see the penultimate value begins with "LIST=". I want to extract the value after this string i.e. "Daily SMS SPL" to be able to compare it with another column in another table. I want to obtain this value ("Daily SMS SPL") using a SELECT query if it's possible.
So let's say the table name is MYTABLE and the name of the column is MYCOLUMN.
SELECT SUBSTR(surname,1
,INSTR(surname,'"',1,1)-1) FROM
(SELECT SUBSTR(column
,INSTR(column,'LIST',-1)+5
) AS surname
FROM table)
FIDDLE
I am using vs 2010 and want to perform a query on sql server database. But i have a problem i want to retrieves a row on the basis of name which i want to retrieves it using second character of name that is i don't know the first character that is for example the name is nik as i enter i it will retrives a record which having nik as value of name column.
Can any one guided me...I know following query what things i have to modified in it.
select * from table1 where name like '"& n % &"'
for example the name is nik as I enter i it will retrives a record which having nik as value of name column
try
select * from table1 where name like '_i%'
TSQL Like