This is a discussion on How to do a select on a column with no repeats within the MySQL forums, part of the Database Server Software category; --> Hello all, I'm needing to do a select on a certain column of a database and have the results ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello all, I'm needing to do a select on a certain column of a database and have the results returned with no repeats. For example, say I have a table of addresses and one of the columns is the state. I have 5 entries in the table and three of them are in the state of Texas. When I do a select for the state from the table I want it to only return Texas as a result only once instead of three times. Is this possible? Thanks! |
| |||
| Oops... I bet I can get what I want if I use the DISTINCT keyword huh... On Dec 28, 8:51 pm, "Bryan" <BTRichard...@gmail.com> wrote: > Hello all, > > I'm needing to do a select on a certain column of a database and have > the results returned with no repeats. For example, say I have a table > of addresses and one of the columns is the state. I have 5 entries in > the table and three of them are in the state of Texas. When I do a > select for the state from the table I want it to only return Texas as a > result only once instead of three times. > > Is this possible? Thanks! |
| |||
| Bryan wrote: > Hello all, > > I'm needing to do a select on a certain column of a database and have > the results returned with no repeats. For example, say I have a table > of addresses and one of the columns is the state. I have 5 entries in > the table and three of them are in the state of Texas. When I do a > select for the state from the table I want it to only return Texas as a > result only once instead of three times. > > Is this possible? Thanks! > http://dev.mysql.com/doc/refman/5.1/en/select.html See the DISTINCT keyword. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
| |||
| Is it possible to do an SQL query on a result set from a previous SQL query? On Dec 28, 8:54 pm, "Bryan" <BTRichard...@gmail.com> wrote: > Oops... I bet I can get what I want if I use the DISTINCT keyword > huh... > > On Dec 28, 8:51 pm, "Bryan" <BTRichard...@gmail.com> wrote: > > > > > Hello all, > > > I'm needing to do a select on a certain column of a database and have > > the results returned with no repeats. For example, say I have a table > > of addresses and one of the columns is the state. I have 5 entries in > > the table and three of them are in the state of Texas. When I do a > > select for the state from the table I want it to only return Texas as a > > result only once instead of three times. > > > Is this possible? Thanks!- Hide quoted text -- Show quoted text - |
| ||||
| Bryan wrote: > Is it possible to do an SQL query on a result set from a previous SQL > query? > > On Dec 28, 8:54 pm, "Bryan" <BTRichard...@gmail.com> wrote: > > Oops... I bet I can get what I want if I use the DISTINCT keyword > > huh... > > > > On Dec 28, 8:51 pm, "Bryan" <BTRichard...@gmail.com> wrote: > > > > > > > > > Hello all, > > > > > I'm needing to do a select on a certain column of a database and have > > > the results returned with no repeats. For example, say I have a table > > > of addresses and one of the columns is the state. I have 5 entries in > > > the table and three of them are in the state of Texas. When I do a > > > select for the state from the table I want it to only return Texas as a > > > result only once instead of three times. > > > > > Is this possible? Thanks!- Hide quoted text -- Show quoted text - Yes (see VIEWS), however I'm sure a brief skim through the manual would answer all these questions. You might even discover how to do the entire query with just one statement (see sub-queries and/or JOINS). |