+ Post New Thread
Results 1 to 3 of 3
Coding Thread, SQL SELECT DISTINCT two tables? in Coding and Web Development; So whats wrong with this? SELECT DISTINCT PSUEDOFIELD_2 FROM (SELECT FIELD2 AS PSUEDOFIELD_2 FROM TABLE2 WHERE CURRENT=1 UNION ALL SELECT ...
  1. #1
    oxide54's Avatar
    Join Date
    Mar 2009
    Posts
    798
    Thank Post
    51
    Thanked 55 Times in 54 Posts
    Rep Power
    22

    SQL SELECT DISTINCT two tables?

    So whats wrong with this?

    SELECT DISTINCT PSUEDOFIELD_2 FROM (SELECT FIELD2 AS PSUEDOFIELD_2 FROM TABLE2 WHERE CURRENT=1 UNION ALL SELECT FIELD1 AS PSUEDOFIELD_2 FROM TABLE1) WHERE PSUEDOFIELD_2 IS NOT NULL AND PSUEDOFIELD_2 <> '' AND PSUEDOFIELD_2 <> ' ';

    this gives me rows? but the PSUEDOFIELD_2 is not distinct ???
    Last edited by oxide54; 28th October 2012 at 06:06 PM.

  2. #2
    oxide54's Avatar
    Join Date
    Mar 2009
    Posts
    798
    Thank Post
    51
    Thanked 55 Times in 54 Posts
    Rep Power
    22
    ignore me, its whitespace differences

  3. #3
    oxide54's Avatar
    Join Date
    Mar 2009
    Posts
    798
    Thank Post
    51
    Thanked 55 Times in 54 Posts
    Rep Power
    22
    ANSWER

    SELECT DISTINCT PSUEDOFIELD_2 FROM (SELECT LTRIM(RTRIM(FIELD2)) AS PSUEDOFIELD_2 FROM TABLE2 WHERE CURRENT=1 UNION ALL SELECT LTRIM(RTRIM(FIELD1)) AS PSUEDOFIELD_2 FROM TABLE1) WHERE PSUEDOFIELD_2 IS NOT NULL AND PSUEDOFIELD_2 <> '' AND PSUEDOFIELD_2 <> ' ';

SHARE:
+ Post New Thread

Similar Threads

  1. What Corrupted an MS SQL 2000 Table ?
    By Richard_Finnigan in forum MIS Systems
    Replies: 8
    Last Post: 26th February 2009, 10:01 PM
  2. Two SQLs on one server?
    By Gibbo in forum Windows
    Replies: 7
    Last Post: 17th July 2008, 11:54 AM
  3. SIMS SQL Server Table Documentation
    By peterteckhokgoh in forum MIS Systems
    Replies: 7
    Last Post: 23rd May 2008, 11:36 AM
  4. SQL Table Location G&T
    By mark80 in forum MIS Systems
    Replies: 2
    Last Post: 16th May 2007, 12:46 PM
  5. Refreshing MS Access linked tables to CMIS MS SQL
    By dickyfinn02 in forum MIS Systems
    Replies: 0
    Last Post: 23rd April 2007, 04:33 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •