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 6015067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:46:57+00:00 2026-05-23T02:46:57+00:00

After reading around, I’ve realized that SQL ( MySQL in my case ) does

  • 0

After reading around, I’ve realized that SQL (MySQL in my case) does not support column exclusion.

SELECT *, NOT excluded_column FROM table; /* shame it doesn't work */

Anyways, while I’ve come to accept that, I’m wondering if there’s any decent workarounds to achieve this sort of behavior. Reason being, I’m creating a view to consolidate information across a few tables.

I’ve normalized some user data to tables user and user_profile among others; purpose being that user stores data critical to user operations, and user_profile stores non-critical data. Application requirements are still being realized, so columns are being added/removed from user_profile as necessary, and further tables may be supported down the line which would be included in the view.

Problem is, when I create the view, I get Error 1060: Duplicate Column Name because user_id is present in both tables.

Now, the solution I’ve come up with so far, is basically:

/* exclude user_id from user */
SELECT user.critical_field, user.other_critical_field,
       user_profile.*
FROM user
LEFT JOIN user_profile
ON user.user_id = user_profile.user_id;

Since the user table is going to remain unchanged throughout the application lifecycle (hopefully) this could suffice, but I was just curious if a more dynamic approach exists.

(Table names were not copypasta’d, I know user is often a poor choice of naming convention on it’s own, I use prefixes.)

  • 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-05-23T02:46:58+00:00Added an answer on May 23, 2026 at 2:46 am

    Typically, I’ll define which fields I want to be in my view

    Using your example:

    SELECT user.critical_field, user.other_critical_field,
           user_profile.User_Id, user_profile.MyOtherOfield
    FROM user
    LEFT JOIN user_profile
    ON user.user_id = user_profile.user_id;
    

    Now, additionally, I’ll make sure that I alias things properly:

    SELECT u.critical_field, u.other_critical_field,
               up.User_Id, up.MyOtherOfield, u.KeyField AS userKey, up.KeyField as ProfileKey
        FROM user as u
        LEFT JOIN user_profile as up
        ON u.user_id = up.user_id;
    

    This allows me to ensure I know what’s in my view, and that the columns are named intelligently, but it does mean that I’ll need to touch that view when I make changes to the underlying table structures.

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

Sidebar

Related Questions

After reading Evan's and Nilsson's books I am still not sure how to manage
I've been struggling to get my mind around classes. Even after reading several websites
After reading this - What does 'synchronized' mean? I was still unable to understand
After reading the Head First Design Patterns book and using a number of other
After reading this question , I was reminded of when I was taught Java
After reading a bit more about how Gnutella and other P2P networks function, I
After reading Practical Common Lisp I finally understood what the big deal about macros
After reading this description of late static binding (LSB) I see pretty clearly what
After reading What’s your/a good limit for cyclomatic complexity? , I realize many of
After reading the answers to the question Calculate Code Metrics I installed the tool

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.