Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7906001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:43:24+00:00 2026-06-03T10:43:24+00:00

I can not find this any where (I am probably not asking the right

  • 0

I can not find this any where (I am probably not asking the right questions). Would someone please point me in the right direction.

I am using a 2 column composite primary key in MySQL.
I would like to display that value as a default value in a 3rd column in the same table and in another table.

Col_1 value = ABC, 
Col_2 value = 123, 
PK          = ABC123, 

Col_3 default value = ABC123 

Would anyone be able to explain how to do this?

I would prefer not to do this with a trigger or an insert statement if possible.

Thanks,

Ted

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:43:25+00:00Added an answer on June 3, 2026 at 10:43 am

    There aren’t many situations where you really need the value to actually be in the column. You can get the same effect many times by creating the value in the select statement you use to fetch the data — or in the php, ruby or whatever code you use to display the data.

    For example:

    SELECT Col_1, Col_2, CONCAT(NEW.Col_1,NEW.Col_2) as Col_3
    FROM my_table;
    

    This will resolve the issue for you while avoiding triggers and other fancy sql tricks.

    I think this is a better approach as well in case someone wants to change the values of Col_1 or Col_2 — if they change one of those values, then a column that held the combination of the two would also have to be updated. It makes things more complex than they need to be.

    If you have some reason they must be in the database table, let us know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have not been able to find any definitive answers to this question: Can
I've searched around but I can't find any information about this; maybe I'm not
all. Maybe i've not googled enough, but i can't find any example on this
I can not find any help on this issue in vs2008 help, Google, or
This is probably a really basic question, but I can't find any answers. I
I think this is a simple question, but I can not find the answer
This is probably pretty simple, but I can't find the answer in the docs.
This has probably been asked before but I can't find it anywhere. I have
i cannot find any documentation of this project
Is there any known attack on this modified version of Yahalom? Cannot find anything...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.