Professional Web Applications Themes

Stop repeat entries - PHP Development

Can you stop pulling out exactly the same data from a database, for example, if you had 2 entries which had the name Chris, it would only print Chris once?...

  1. #1

    Default Stop repeat entries

    Can you stop pulling out exactly the same data from a database, for
    example, if you had 2 entries which had the name Chris, it would only
    print Chris once?
    Damien Guest

  2. #2

    Default Re: Stop repeat entries

    Damien wrote:
    > Can you stop pulling out exactly the same data from a database, for
    > example, if you had 2 entries which had the name Chris, it would only
    > print Chris once?
    You could use SQL's DISTINCT keyword, but that would only work if every
    row in your resultset would be a match.

    for instance, given the table

    fname | lname
    ------+------
    Chris | Smith
    Chris | Jones

    SELECT DISTINCT(fname) FROM tblName WHERE fname='Chris' would work, where

    SELECT DISTINCT(*) FROM tblName WHERE fname='Chris' wouldn't.

    You might be able to do it with some nasty JOINs but those are evil and
    kill your performance.

    Joshua Ghiloni Guest

  3. #3

    Default Re: Stop repeat entries

    Actualy, if you are using SQL, I would use a LIMIT command as follows

    SELECT fname FROM table WHERE fname = Chris LIMIT 1;

    --
    Your GP or your HP!
    Warren Butt

    "Joshua Ghiloni" <jdg11SPAM.ME.AND.DIE.cwru.edu> wrote in message
    news:bg1ctt$7ia$1eeyore.INS.cwru.edu...
    > Damien wrote:
    > > Can you stop pulling out exactly the same data from a database, for
    > > example, if you had 2 entries which had the name Chris, it would only
    > > print Chris once?
    >
    > You could use SQL's DISTINCT keyword, but that would only work if every
    > row in your resultset would be a match.
    >
    > for instance, given the table
    >
    > fname | lname
    > ------+------
    > Chris | Smith
    > Chris | Jones
    >
    > SELECT DISTINCT(fname) FROM tblName WHERE fname='Chris' would work, where
    >
    > SELECT DISTINCT(*) FROM tblName WHERE fname='Chris' wouldn't.
    >
    > You might be able to do it with some nasty JOINs but those are evil and
    > kill your performance.
    >

    DjDrakk Guest

  4. #4

    Default Re: Stop repeat entries

    Joshua Ghiloni wrote:
    > Damien wrote:
    >
    >> Can you stop pulling out exactly the same data from a database, for
    >> example, if you had 2 entries which had the name Chris, it would only
    >> print Chris once?
    >
    >
    > You could use SQL's DISTINCT keyword, but that would only work if every
    > row in your resultset would be a match.
    >
    > for instance, given the table
    >
    > fname | lname
    > ------+------
    > Chris | Smith
    > Chris | Jones
    >
    > SELECT DISTINCT(fname) FROM tblName WHERE fname='Chris' would work, where
    >
    > SELECT DISTINCT(*) FROM tblName WHERE fname='Chris' wouldn't.
    >
    > You might be able to do it with some nasty JOINs but those are evil and
    > kill your performance.
    >
    Yes forget I said all this. I've been at work too long today, and I'm
    tired :)

    Joshua Ghiloni Guest

Similar Threads

  1. background-repeat: repeat-x in HTML? Please help!
    By maynardt in forum Macromedia Dynamic HTML
    Replies: 3
    Last Post: June 16th, 12:52 PM
  2. STOP=Save The Opticles People! ... Stop Flashs flashing!
    By vpool78 in forum Macromedia Flash Player
    Replies: 1
    Last Post: October 17th, 03:58 PM
  3. Replies: 0
    Last Post: August 14th, 05:08 PM
  4. Stop Debugging doesn't stop in ASP.NET
    By Matt Theule in forum ASP.NET General
    Replies: 7
    Last Post: July 24th, 07:38 PM
  5. how to stop director when in endless repeat loop ??
    By luk in forum Macromedia Director Basics
    Replies: 3
    Last Post: July 10th, 01:29 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139