Connecting Tech Pros Worldwide
 
 
sign in | join about | help | sitemap
[ http://bytes.com/adLoader.php?parent=database
lmeeson's Avatar

Combining two fields


Question posted by: lmeeson (Newbie) on October 3rd, 2008 03:20 PM
i want to combine two fields and have used the the following query
Expand|Select|Wrap|Line Numbers
UPDATE SudentInfo SET  image1name = CONCAT(imagepath,UserName,'1');

this works but the thing is when a new record is added the query is not applied and i have to manually execute the query again.

Is there a way to automate this so that the query is applied to all subsequent records?
Cheers
post reply
Quote | Subscribe
5 Answers Posted
Atli's Avatar
Moderator - 2,750 Posts
#2: Re: Combining two fields

Hi.

Why do you want to duplicate your data like that?

It would make much more sense to combine the fields when the data is read, rather then storing duplicates of data that already exists.

However, if you want to do it this way, you could look into Triggers.
tomarvijay80's Avatar
Newbie - 10 Posts
#3: Re: Combining two fields

Ya, u can use trigers for updating columns or the other way is to concatenate columns while fetching records.
lmeeson's Avatar
Newbie - 4 Posts
#4: Re: Combining two fields

I needed to combine two fields into one, so i executed this query

UPDATE Students SET
image1 = CONCAT(imagepath, image1name);

This worked, but the problem is that whenever a new record is added i have to manually re-enter and execute the query, is there any way to achieve the same outcome (image1 = imagepath+image1name) for all subsequent records that would be entered, without me having to do it manually?
ak1dnar's Avatar
Moderator - 1,397 Posts
#5: Re: Combining two fields

are you using this query in a application or how you going to get those two values to that query? is it a user input? be more specific with your question.
Atli's Avatar
Moderator - 2,750 Posts
#6: Re: Combining two fields

lmeeson.

Do NOT double post your questions!
This only serves to cause confusion and is highly disrespectful of those of us that have taken the time to answer your first post.

Please read and follow the Posting Guidelines when posting in these forums, or risk getting your account banned.

I have merged your new thread into this one.
If the answers we provided do not work for you, explain why and we may be able to provide alternate solutions.

Also, please use [code] tags when posting code examples.
This makes them easier to read and thus, makes it easier for us to help you.

Thank you
Moderator
Reply
Not the answer you were looking for? Post your question . . .
196,220 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,220 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top MySQL Contributors

[ http://bytes.com/adLoader.php?parent=database


You are viewing a mobilized version of this site...
View original page here

How do you rate mobile version of this page?

Mobilized by Mowser Mowser