mysql selecting distinct in one collumn but retrieving all the the other cols too

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

    mysql selecting distinct in one collumn but retrieving all the the other cols too

    hi!

    is it possible to do the aforementioned query - selecting only distinct
    in 1 col but retrieving all other cols at the same time.

    regards

    marc

  • monomaniac21

    #2
    Re: mysql selecting distinct in one collumn but retrieving all the the other cols too

    heres the query im trying (well one variant):

    $result = mysql_query("SE LECT name, id FROM tblproducts WHERE category
    = '$category_get' & name = DISTINCT ORDER BY name ASC LIMIT 0,8");

    also tried: "select distinct name, id.." to no avail...


    monomaniac21 wrote:
    hi!
    >
    is it possible to do the aforementioned query - selecting only distinct
    in 1 col but retrieving all other cols at the same time.
    >
    regards
    >
    marc

    Comment

    • flamer die.spam@hotmail.com

      #3
      Re: mysql selecting distinct in one collumn but retrieving all the the other cols too


      monomaniac21 wrote:
      heres the query im trying (well one variant):
      >
      $result = mysql_query("SE LECT name, id FROM tblproducts WHERE category
      = '$category_get' & name = DISTINCT ORDER BY name ASC LIMIT 0,8");
      >
      also tried: "select distinct name, id.." to no avail...
      >
      >
      monomaniac21 wrote:
      hi!

      is it possible to do the aforementioned query - selecting only distinct
      in 1 col but retrieving all other cols at the same time.

      regards

      marc
      what do you mean exactly?? you can do:
      $result = mysql_query("SE LECT * FROM tblproducts WHERE category
      = '$category_get' & name = DISTINCT ORDER BY name ASC LIMIT 0,8");

      that will select all the fields from each row that matches your where
      clause..

      Flamer.

      Comment

      • monomaniac21

        #4
        Re: mysql selecting distinct in one collumn but retrieving all the the other cols too

        you cant do this query:

        SELECT * FROM tblproducts WHERE name = DISTINCT ORDER BY date_added
        DESC, name ASC LIMIT 0,8

        mysql wont allow it. by distinct im referring to unique values not the
        string value equal to distinct.

        can anyone help me with a query that can do this?


        flamer die.spam@hotmai l.com wrote:
        monomaniac21 wrote:
        >
        heres the query im trying (well one variant):

        $result = mysql_query("SE LECT name, id FROM tblproducts WHERE category
        = '$category_get' & name = DISTINCT ORDER BY name ASC LIMIT 0,8");

        also tried: "select distinct name, id.." to no avail...


        monomaniac21 wrote:
        hi!
        >
        is it possible to do the aforementioned query - selecting only distinct
        in 1 col but retrieving all other cols at the same time.
        >
        regards
        >
        marc
        >
        what do you mean exactly?? you can do:
        $result = mysql_query("SE LECT * FROM tblproducts WHERE category
        = '$category_get' & name = DISTINCT ORDER BY name ASC LIMIT 0,8");
        >
        that will select all the fields from each row that matches your where
        clause..
        >
        Flamer.

        Comment

        • Jerry Stuckle

          #5
          Re: mysql selecting distinct in one collumn but retrieving all thethe other cols too

          monomaniac21 wrote:
          you cant do this query:
          >
          SELECT * FROM tblproducts WHERE name = DISTINCT ORDER BY date_added
          DESC, name ASC LIMIT 0,8
          >
          mysql wont allow it. by distinct im referring to unique values not the
          string value equal to distinct.
          >
          can anyone help me with a query that can do this?
          >
          >
          flamer die.spam@hotmai l.com wrote:
          >
          >>monomaniac2 1 wrote:
          >>
          >>
          >>>heres the query im trying (well one variant):
          >>>
          >>> $result = mysql_query("SE LECT name, id FROM tblproducts WHERE category
          >>>= '$category_get' & name = DISTINCT ORDER BY name ASC LIMIT 0,8");
          >>>
          >>>also tried: "select distinct name, id.." to no avail...
          >>>
          >>>
          >>>monomaniac 21 wrote:
          >>>
          >>>>hi!
          >>>>
          >>>>is it possible to do the aforementioned query - selecting only distinct
          >>>>in 1 col but retrieving all other cols at the same time.
          >>>>
          >>>>regards
          >>>>
          >>>>marc
          >>
          >>what do you mean exactly?? you can do:
          >>$result = mysql_query("SE LECT * FROM tblproducts WHERE category
          >= '$category_get' & name = DISTINCT ORDER BY name ASC LIMIT 0,8");
          >>
          >>that will select all the fields from each row that matches your where
          >>clause..
          >>
          >>Flamer.
          >
          >
          Maybe you should ask MySQL questions in a group such as
          comp.databases. mysql - where the MySQL gurus hang out?

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

          Comment

          Working...