SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    dublin
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question select row with not repetitive colunm value

    Hallo guys,

    It is posible to select the rows which contain a values in a column that only come out once wihtout using subqueries.

    A B C
    1 f s
    2 j k
    1 l p
    3 u o

    In this expample only the row that have the no repetitive values in the column A. Therefore :

    2 j k
    3 u o

    Thanks in advance.

    Nora

  2. #2
    SitePoint Addict
    Join Date
    Feb 2004
    Location
    Staffordshire, UK & Florida, USA
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SELECT a, b, c FROM table GROUP BY a HAVING COUNT(a) = 1

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    djones, that won't work in any database other than mysql, because the GROUP BY is wrong (see 12.9.3 GROUP BY with Hidden Fields)
    Code:
    select t1.a
         , t1.b
         , t1.c 
      from yourtable as t1
    inner
      join yourtable as t2
        on t1.a
         = t2.a
    group
        by t1.a
         , t1.b
         , t1.c 
    having count(*) = 1
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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