Jump to content

[SQL] Function output into record

Go to solution Solved by CJPowell27,

MODS go ahead and delete this I did some random stuff and it worked!

update tableName set initials=(select concat(substring(first_name,1,1),substring(last_name,1,1))); it's ugly but it works

Hey guys I am trying to have automatically fill the a column with output from another function. So basically my table has a first name and a last name column and I am trying to fill an initials column with the first letter from each of the other two columns. So for example the following:

first_name | last_name | initials

John          | Smith         |

 

would populate the initials column with JS. I can't think of a keyword that I have learned yet that allows me to update existing columns with output from any function that would give me the initials like concat(substring(first_name,1,1),substring(last_name,1,1);

i5 4670k| Asrock H81M-ITX| EVGA Nex 650g| WD Black 500Gb| H100 with SP120s| ASUS Matrix 7970 Platinum (just sold)| Patriot Venom 1600Mhz 8Gb| Bitfenix Prodigy. Build log in progress 

Build Log here: http://linustechtips.com/main/topic/119926-yin-yang-prodigy-update-2-26-14/

Link to comment
https://linustechtips.com/topic/1317323-sql-function-output-into-record/
Share on other sites

Link to post
Share on other sites

MODS go ahead and delete this I did some random stuff and it worked!

update tableName set initials=(select concat(substring(first_name,1,1),substring(last_name,1,1))); it's ugly but it works

i5 4670k| Asrock H81M-ITX| EVGA Nex 650g| WD Black 500Gb| H100 with SP120s| ASUS Matrix 7970 Platinum (just sold)| Patriot Venom 1600Mhz 8Gb| Bitfenix Prodigy. Build log in progress 

Build Log here: http://linustechtips.com/main/topic/119926-yin-yang-prodigy-update-2-26-14/

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×