Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distinct in select causing trouble

Status
Not open for further replies.

Xenocide

Programmer
Jan 20, 2005
76
CA
Hi

I'm doing this query

SELECT DISTINCT [Table850].[Maitre], [Table850].Description]
FROM Table850
WHERE ((([Table850].[Maitre])<>""));


seem like someone doesn't like me cauz when I run this query the distinct ain't working

somebody can help me?
 
Why not do:

Code:
SELECT Maitre, Description
FROM table 850
WHERE Maitre <> ""
GROUP BY Maitre, Description
 
I am surprised that you are using
Maitre<>""
since most fields by default can't contain zero-length-strings. I don't think I have ever created a table where this expression would exclude any records. Your application is very possibly different.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Should work, maybe there are trailing spaces confusing the issue.

Also in your code as posted there is a missing [ in front of Description]
 
SELECT DISTINCT Maitre, Description
FROM Table850
WHERE Trim([Maitre] & "")<>"";

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
... Distinct isn't working ... as in ... duplicate records are appearing ...?

Or are you saying that the where clause isn't returning records where [Maitre] <> "" ?

Try something like
Code:
SELECT DISTINCT [Maitre], [Description]
FROM Table850
WHERE Len(Trim([Maitre])) > 0

OR

Code:
SELECT DISTINCT [Maitre], [Description]
FROM Table850
WHERE [Maitre] IS NOT NULL

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top