Jump to content

Adding flags to resultset


cyberRobot

Recommended Posts

I'm using UNION to merge two resultsets. Everything works, but I trying to figure out how to add a flag to the resultset.

 

Basically I have a table for pre-defined stakeholders and a table for other stakeholders. Since I'll be using the id from both tables and it may overlap, I would like to create a flag to indicate if its an other stakeholder or not.

 

Here is my query so far:

(SELECT id, org, type FROM stakeholders) 
UNION 
(SELECT id, orgOther, orgOtherType FROM otherStakeholders) 
ORDER BY type, org

 

Here is the "stakeholders" table:

idorgtype

1s1National

2s2State/Local

3s3State/Local

4s4National

 

Here is the "otherStakeholders" table:

idorgOtherorgOtherType

1other_s1National

2other_s2State/Local

 

 

Note that the otherStakeholders table has been simplified...there is a reason why it's stored in a seperate table.  :P

 

Also, I'm using MySQL 5.0 if it matters.

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.