Distinct down

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gandalf

    Distinct down

    Hi everyone,
    How can I pull out unique data from the end of a table, and not from
    the start?

    thanks

  • Gandalf

    #2
    Re: Distinct down

    On Jun 16, 5:23 pm, Gandalf <goldn...@gmail .comwrote:

    I feel like I need to explain it more clearly.

    Like the last users that watch my card in a date site. I wont that if
    I entered both month ago and second ago the query steel pull me as the
    last user that entered the card

    Comment

    • Michael Fesser

      #3
      Re: Distinct down

      ..oO(Gandalf)
      >On Jun 16, 5:23 pm, Gandalf <goldn...@gmail .comwrote:
      >
      >I feel like I need to explain it more clearly.
      >
      >Like the last users that watch my card in a date site. I wont that if
      >I entered both month ago and second ago the query steel pull me as the
      >last user that entered the card
      Still confusing, but do you want to get the last entry from a database
      table? Then you have to implement something to get the records in a
      specific order (database records don't have any specific order by
      default), for example the date when the record was inserted or updated.
      Then sorting by date and fetching the last record is trivial.

      Micha

      Comment

      • Gandalf

        #4
        Re: Distinct down

        On Jun 16, 8:37 pm, Michael Fesser <neti...@gmx.de wrote:
        .oO(Gandalf)
        >
        On Jun 16, 5:23 pm, Gandalf <goldn...@gmail .comwrote:
        >
        I feel like I need to explain it more clearly.
        >
        Like the last users that watch my card in a date site. I wont that if
        I entered both month ago and second ago the query steel pull me as the
        last user that entered the card
        >
        Still confusing, but do you want to get the last entry from a database
        table? Then you have to implement something to get the records in a
        specific order (database records don't have any specific order by
        default), for example the date when the record was inserted or updated.
        Then sorting by date and fetching the last record is trivial.
        >
        Micha
        When user enter other user card there's a registry of the both user's
        id and the auto increment number that uses as row id.
        Now when I write this query :
        "select distinct visit from `last_users` where host='$_REQUEST[num]'
        order by id desc limit 10"
        I get the last 10 users that visit the host card only if it's their
        first time to visit him. otherwise the query consider there first
        entry as the unique row.
        I hope I explained it better now.

        thank you

        Comment

        • Jerry Stuckle

          #5
          Re: Distinct down

          Gandalf wrote:
          On Jun 16, 8:37 pm, Michael Fesser <neti...@gmx.de wrote:
          >.oO(Gandalf)
          >>
          >>On Jun 16, 5:23 pm, Gandalf <goldn...@gmail .comwrote:
          >>I feel like I need to explain it more clearly.
          >>Like the last users that watch my card in a date site. I wont that if
          >>I entered both month ago and second ago the query steel pull me as the
          >>last user that entered the card
          >Still confusing, but do you want to get the last entry from a database
          >table? Then you have to implement something to get the records in a
          >specific order (database records don't have any specific order by
          >default), for example the date when the record was inserted or updated.
          >Then sorting by date and fetching the last record is trivial.
          >>
          >Micha
          >
          When user enter other user card there's a registry of the both user's
          id and the auto increment number that uses as row id.
          Now when I write this query :
          "select distinct visit from `last_users` where host='$_REQUEST[num]'
          order by id desc limit 10"
          I get the last 10 users that visit the host card only if it's their
          first time to visit him. otherwise the query consider there first
          entry as the unique row.
          I hope I explained it better now.
          >
          thank you
          >
          First of all, this is not a PHP question - it's a database question.
          You should be asking in a database-related newsgroup.

          Second, as Michael indicated, you need something to sort on. If you
          don't store a timestamp or something relating to when the user signs on,
          you have nothing to sort on.

          I'd suggest you follow up in the appropriate newsgroup.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Gandalf

            #6
            Re: Distinct down

            On Jun 16, 11:02 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
            Gandalf wrote:
            On Jun 16, 8:37 pm, Michael Fesser <neti...@gmx.de wrote:
            .oO(Gandalf)
            >
            >On Jun 16, 5:23 pm, Gandalf <goldn...@gmail .comwrote:
            >I feel like I need to explain it more clearly.
            >Like the last users that watch my card in a date site. I wont that if
            >I entered both month ago and second ago the query steel pull me as the
            >last user that entered the card
            Still confusing, but do you want to get the last entry from a database
            table? Then you have to implement something to get the records in a
            specific order (database records don't have any specific order by
            default), for example the date when the record was inserted or updated.
            Then sorting by date and fetching the last record is trivial.
            >
            Micha
            >
            When user enter other user card there's a registry of the both user's
            id and the auto increment number that uses as row id.
            Now when I write this query :
            "select distinct visit from `last_users` where host='$_REQUEST[num]'
            order by id desc limit 10"
            I get the last 10 users that visit the host card only if it's their
            first time to visit him. otherwise the query consider there first
            entry as the unique row.
            I hope I explained it better now.
            >
            thank you
            >
            First of all, this is not a PHP question - it's a database question.
            You should be asking in a database-related newsgroup.
            >
            Second, as Michael indicated, you need something to sort on. If you
            don't store a timestamp or something relating to when the user signs on,
            you have nothing to sort on.
            >
            I'd suggest you follow up in the appropriate newsgroup.
            >
            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstuck...@attgl obal.net
            =============== ===
            Ho, I'm sorry. It seemed very related, and sens you guys where always
            so nice and helpful I assume you wold not mine....

            Comment

            • Jerry Stuckle

              #7
              Re: Distinct down

              Gandalf wrote:
              On Jun 16, 11:02 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
              >Gandalf wrote:
              >>On Jun 16, 8:37 pm, Michael Fesser <neti...@gmx.de wrote:
              >>>.oO(Gandal f)
              >>>>On Jun 16, 5:23 pm, Gandalf <goldn...@gmail .comwrote:
              >>>>I feel like I need to explain it more clearly.
              >>>>Like the last users that watch my card in a date site. I wont that if
              >>>>I entered both month ago and second ago the query steel pull me as the
              >>>>last user that entered the card
              >>>Still confusing, but do you want to get the last entry from a database
              >>>table? Then you have to implement something to get the records in a
              >>>specific order (database records don't have any specific order by
              >>>default), for example the date when the record was inserted or updated.
              >>>Then sorting by date and fetching the last record is trivial.
              >>>Micha
              >>When user enter other user card there's a registry of the both user's
              >>id and the auto increment number that uses as row id.
              >>Now when I write this query :
              >>"select distinct visit from `last_users` where host='$_REQUEST[num]'
              >>order by id desc limit 10"
              >> I get the last 10 users that visit the host card only if it's their
              >>first time to visit him. otherwise the query consider there first
              >>entry as the unique row.
              >>I hope I explained it better now.
              >>thank you
              >First of all, this is not a PHP question - it's a database question.
              >You should be asking in a database-related newsgroup.
              >>
              >Second, as Michael indicated, you need something to sort on. If you
              >don't store a timestamp or something relating to when the user signs on,
              >you have nothing to sort on.
              >>
              >I'd suggest you follow up in the appropriate newsgroup.
              >>
              >--
              >============== ====
              >Remove the "x" from my email address
              >Jerry Stuckle
              >JDS Computer Training Corp.
              >jstuck...@attg lobal.net
              >============== ====
              >
              Ho, I'm sorry. It seemed very related, and sens you guys where always
              so nice and helpful I assume you wold not mine....
              >
              It's always best to ask in a newsgroup related to your product. Others
              might be helpful - but the correct newsgroup has the experts.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              Working...