mrichardson 57577 (6/13/2013)
I would like to select distinct values from 1 column in my query.
If I was selecting just 1 column in a simple query it would probably work, but I've got a more complex query and having trouble with it.
here is my code:
SELECT db.myTable.myFieldId, db.myFields.ModuleId, db.myTable.FieldValue
FROM db.myTable INNER JOIN
db.myFields ON db.myTable.myFieldId = db.myFields.myFieldId INNER JOIN
db.myRows ON db.myTable.myRowId = db.myRows.myRowId
WHERE (db.myFields.ModuleId = 1397) AND (db.myTable.myFieldId = 221)
The part I want to be distinct is this bit: db.myTable.FieldValue
If I insert the word 'distinct' before it, an error returns saying I can't do this.
If your base data was like this:
(myFieldId, ModuleId, FieldValue)
and you want 'FieldValue' to be distinct, which version of myFieldId and moduleId would you want to display?
Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this
If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.
Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.