0

I have several tables that have similar fields, for example, Name and Email address:

TABLE Users (
   Name varchar(255),
   Email varchar(255),
   etc..
)

TABLE Clients (
  Name varchar(255),
  Email varchar(255),
  etc..
)

TABLE Administrators (
  Name varchar(255),
  Email varchar(255),
  etc..
)

I'd like to get a list of all names and email address, and be able to filter out duplicate addresses across tables (i.e. a client and a user may both have the same email address)

1 Answer 1

2

Well, you could try:

SELECT DISTINCT Name, Email FROM
  (SELECT Name, Email FROM Users
   UNION
   SELECT Name, Email FROM Clients
   UNION
   SELECT Name, Email FROM Administrators) p
Sign up to request clarification or add additional context in comments.

4 Comments

@SashiKant: no, it doesn't!! Did you try it?
@SashiKant: no, if you copy my query you won't get that error, absolutely not!! Now I've also tested it, so be sure it's correct :)
No actually I tailered it, according to the tables i m having, its working now, thanks... hey plz help me with this query stackoverflow.com/questions/8416117/…
@SashiKant: I don't understand: question is yours? Or is from @GSto?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.