Professional Web Applications Themes

Problem with query... - MySQL

Hi I have a database that has some repeatnig variables in the same column... Is it possible to return rows from this column one by one, but avoiding repeating variables? How such a query should look like? (I think about while loop in php) I need this to make dropdown list. Thanks Leszek...

  1. #1

    Default Problem with query...

    Hi
    I have a database that has some repeatnig variables in the same column...
    Is it possible to return rows from this column one by one, but avoiding
    repeating variables? How such a query should look like? (I think about while
    loop in php)

    I need this to make dropdown list.

    Thanks
    Leszek


    Leszek Guest

  2. #2

    Default Re: Problem with query...

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Leszek wrote:
    > Hi
    > I have a database that has some repeatnig variables in the same column...
    > Is it possible to return rows from this column one by one, but avoiding
    > repeating variables? How such a query should look like? (I think about while
    > loop in php)
    >
    You may look for SQL keywords like DISTINCT or GROUP BY.

    Regards
    Stefan
    > I need this to make dropdown list.
    >
    > Thanks
    > Leszek
    >
    >
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.1rc2 (MingW32)

    iD8DBQFDtGJmyeCLzp/JKjARApcNAJ4xkgy3gygtXjzNEkvX5S0IgFTASACgiMeP
    MjmHKUOjPqorP+XNkoMMhEc=
    =Ubfo
    -----END PGP SIGNATURE-----
    Stefan Rybacki Guest

  3. #3

    Default Re: Problem with query...

    If the table has a column named "age" with repeated values, then

    SELECT distict age FROM <table name>

    IF you need to include any condition, use as below.

    SELECT distinct age FROM <table name> WHERE <condition>

    Ramya Guest

  4. #4

    Default Re: Problem with query...

    If you have a table with column named "age" and it has repeated values.

    SELECT DISTINCT age FROM <table name>

    Else if you need to use any condition while fetching data,
    then use the below query

    SELECT DISTINCT age FROM <table name> WHERE <condition>

    Ramya Guest

  5. #5

    Default Re: Problem with query...

    SELECT distict age FROM <table name>
    sorry
    the above query should be

    SELECT distinct age FROM <table name>

    Ramya Guest

Similar Threads

  1. Query problem, please help.
    By Raphael Emportu in forum MySQL
    Replies: 2
    Last Post: April 27th, 10:14 AM
  2. Query of Query problem
    By JakeFlynn in forum Macromedia ColdFusion
    Replies: 18
    Last Post: August 11th, 08:15 AM
  3. Query on Query and CF casting problem
    By obxlefty in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: May 18th, 12:44 PM
  4. Sub Query problem
    By Buda123 in forum Coldfusion Database Access
    Replies: 3
    Last Post: April 28th, 08:55 PM
  5. WHERE query problem
    By PegasusT4 in forum Coldfusion Database Access
    Replies: 1
    Last Post: April 28th, 03:56 AM

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