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

  • SEARCH
  • Home
  • 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 7893795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:13:32+00:00 2026-06-03T07:13:32+00:00

Suppose I have columns col1 , col2 , col3 , col4 in myTable and

  • 0

Suppose I have columns col1, col2, col3, col4 in myTable and I need to print out the values exclusive to only one column .

So if the above looks like

  col1    col2    col3    col4
  s        e       c        b 
  c        c       a        s
  n        s       e        a
  d        d       q        c

Then the output should be n, q b since they are exclusive only to col1, col3 and col4 respectively.

How can I achieve this through a query in mysql php?

EDIT The duplicates dont have to be in a single row .I have changed the the table layout now to make it clear.

  • 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-03T07:13:33+00:00Added an answer on June 3, 2026 at 7:13 am

    If you are looking for a SQL-only solution, you can do a query per column like this:

    SELECT 
        col1 AS unique_on_col1
    FROM table
    WHERE     col1 NOT IN (SELECT col2 FROM table)
          AND col1 NOT IN (SELECT col3 FROM table)
          AND col1 NOT IN (SELECT col4 FROM table)
    

    It’s possible to combine all four queries with UNION but that may not be necessary depending on what you want to do with the data. Also, this query should not perform very well with large datasets.

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

Sidebar

Related Questions

Suppose I have a table ABC and table XYZ. Columns of ABC-->col1 col2 col3
Suppose I have a table like this: id col1 col2 col3 1 a 1
Suppose I have a set of column definitions: Col1: value11 value12 value13 Col2: value21
suppose that I have this RDBM table ( Entity-attribute-value_model ): col1: entityID col2: attributeName
Suppose I have two columns in a table that represents a graph, the first
Suppose I have a table with four columns: ID, ParentID, Timestamp, Value. The ParentID
Suppose I have tables T1 and T2 Columns of T1 -->Value Columns of T2
Suppose I have a database table with columns a, b, and c. I plan
Suppose that you have a data frame with many rows and many columns. The
Suppose I have a table with columns (DayId, RunningTotal): DayId RunningTotal --------------------- 1 25

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.