Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2010
    Posts
    2

    Unanswered: sql logic and code question

    here(image link) how my table is going to look like;

    db screenshot on Flickr - Photo Sharing!

    supposing i want to print a message tells who live in the same home

    if their street and door numbers are the same.

    ex:

    ahmet,hakan,kaan(name) live at the same home
    irem,semih live at the same home

    how can i figure out the sql code here?
    thx for your answers!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT t.name
         , t.surname
         , t.street
         , t.door
      FROM ( SELECT street
                  , door
               FROM daTable
             GROUP
                 BY street
                  , door
             HAVING COUNT(*) > 1 ) AS d
    INNER
      JOIN daTable AS t
        ON t.street = d.street
       AND t.door   = d.door
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jul 2010
    Posts
    2
    thank you very much. it works fine.

    can we add an "id " cloumn which has same id inputs for same "street and door" s? so that i can say same id's live at same place.

    it's ok if you suggest another way, thx again

Posting Permissions

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