Combining two fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lmeeson
    New Member
    • Oct 2008
    • 4

    Combining two fields

    i want to combine two fields and have used the the following query
    [CODE=mysql]UPDATE SudentInfo SET
    image1name = CONCAT(imagepat h,UserName,'1') ;[/CODE]
    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
    Last edited by Atli; Oct 3 '08, 11:44 PM. Reason: Added [code] tags.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    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.

    Comment

    • tomarvijay80
      New Member
      • Nov 2006
      • 10

      #3
      Ya, u can use trigers for updating columns or the other way is to concatenate columns while fetching records.

      Comment

      • lmeeson
        New Member
        • Oct 2008
        • 4

        #4
        automatically executing query

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

        UPDATE Students SET
        image1 = CONCAT(imagepat h, 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+image 1name) for all subsequent records that would be entered, without me having to do it manually?

        Comment

        • ak1dnar
          Recognized Expert Top Contributor
          • Jan 2007
          • 1584

          #5
          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.

          Comment

          • Atli
            Recognized Expert Expert
            • Nov 2006
            • 5062

            #6
            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

            Comment

            Working...