Join two tables and select distinct

Posted on 2006-05-23
Last Modified: 2012-06-22
Hi All,

I have to tables

users table  -- user_email(field)

mail_list table -- email(field)

output should be like this (distinct_email) ordered

I want to join two tables, and select disctinc email adres

thanks in advance

Question by:nurbek
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    select user_email from users
    select email from mail_list
    order by 1
    LVL 13

    Author Comment

    thanks for your quick reply

    It works,

    could you please explain order by 1?

    LVL 142

    Accepted Solution

    the order by 1 will order by the first field in the select list, hence your email field
    LVL 13

    Author Comment


    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Introduced in Microsoft SQL Server 2005, the Copy Database Wizard ( is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
    I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
    Via a live example, show how to setup several different housekeeping processes for a SQL Server.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now