Jump to content

combining resultset from two columns into one...


mkosmosports

Recommended Posts

Hey everyone,

Ive got this query:
SELECT DISTINCT DATE_FORMAT(START_DATE,'%Y%m') AS date, TEAM_ID as tid,  OLDCLUB_ID as tid2 from sf_team_player WHERE OLDCLUB_ID IS NOT NULL ORDER BY START_DATE DESC

TEAM_ID as tid,  OLDCLUB_ID as tid2. I want to combine these two selections so they produce only one resultset. So basically select tid and tid2 would produce one resultset of those two without any duplicates.

Any ideas?

Thanks.
Link to comment
Share on other sites

I can't really tell what you've got going on from your post. I don't see any GROUP BY and it looks like tid and tid2 are from the same row in the database. And I'm not sure why you'd want DISTINCT for date. Are there multiple entries for each team?

Anyhow you can combine two rows using CONCAT() eg. CONCAT(TEAM_ID, '-', OLDCLUB_ID) AS id. You can then sort or group by that combined field. You can combine result sets using UNION, but I don't think thats what you're trying to do here.
Link to comment
Share on other sites

True artacus, my initial post is a little confusing. Ive narrowed it down to this though. How can I take distinct values from two columns together instead of each column separately. I mean so:

SELECT DISTINCT TEAM_ID, OLDCLUB_ID from sf_team_player

This will get me distinct values from TEAM_ID and OLDCLUB_ID separately . The thing is I want distinct values from both of these columns at once.

Is that clearer? Any ideas?

Thanks.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.