Capitalization of multiple words in one query [message #629551] |
Wed, 10 December 2014 11:20 |
|
Malkav
Messages: 4 Registered: December 2014 Location: Barcelona
|
Junior Member |
|
|
Hi to everyone, thanks for reading and sorry for my english.
I must capitalize a list of words in diferent entries of the same table.
I have a query that does it, but just with one word at a time.
I want to know if there is a way to capitalize the first character of all the words in a list for all the entries.
This is what I have:
SELECT rre_reference_id AS reference_id, rre_ref_title AS reference_title, REPLACE(rre_ref_title, 'alzheimer', INITCAP('alzheimer'))
FROM adminoltp.ref_references
WHERE rre_ref_title LIKE '%alzheimer%';
I can do that with all the words, not just "alzheimer"; but I don't know how to do it with one query.
Thank you for your time,
Carlos.
Edit: It's a select but I will change it to an update.
[Updated on: Wed, 10 December 2014 11:21] Report message to a moderator
|
|
|
|
Re: Capitalization of multiple words in one query [message #629575 is a reply to message #629553] |
Thu, 11 December 2014 02:49 |
|
Malkav
Messages: 4 Registered: December 2014 Location: Barcelona
|
Junior Member |
|
|
Hello Michel, thank you for your answer.
I don't know what more is needed. I want to update a column, capitalizing the first character of the words that are in a list.
Table is "ref_references", and contains one column called "rre_ref_title" that is VARCHAR2(600) (the title of the reference). If that column contains words like "alzheimer", "parkinson", "hepatitis"; I should update just that words to "Alzheimer", "Parkinson", "Hepatitis".
That query can update one word at a time. But is there a way to replace a list of words in one query?
UPDATE adminoltp.ref_references
SET rre_ref_title = REPLACE(rre_ref_title, 'alzheimer', INITCAP('alzheimer'))
WHERE rre_ref_title LIKE '%alzheimer%';
If you need any info, please ask.
Thank you.
|
|
|
|
Re: Capitalization of multiple words in one query [message #629577 is a reply to message #629576] |
Thu, 11 December 2014 03:42 |
|
Malkav
Messages: 4 Registered: December 2014 Location: Barcelona
|
Junior Member |
|
|
To create the table:
CREATE TABLE REF_REFERENCES
( RRE_REFERENCE_ID NUMBER(8) NOT NULL,
RRE_REFERENCE_TITLE VARCHAR2(600)
);
To fill the table:
INSERT INTO REF_REFERENCES (RRE_REFERENCE_ID, RRE_REFERENCE_TITLE)
VALUES (1, 'Waldheim brain drugs for alzheimer and alcoholism');
INSERT INTO REF_REFERENCES (RRE_REFERENCE_ID, RRE_REFERENCE_TITLE)
VALUES (2, 'DRD4 genotype and activity level predict alzheimers in the oldest-old');
INSERT INTO REF_REFERENCES (RRE_REFERENCE_ID, RRE_REFERENCE_TITLE)
VALUES (3, 'Chiron reports cloning of hepatitis C virus protein');
Expected behaviour:
Update first letter of the words hepatitis, alzheimer, crohn, etc. in one query.
Thank you.
[Updated on: Thu, 11 December 2014 03:43] Report message to a moderator
|
|
|
|
|
|
|