473,409 Members | 1,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

DISTINCT or DISTINCTROW does not work

Hello everyone,

I've tried both DISTINCT or DISTINCTROW in the following query in a PHP
script. But the results still contain duplicate records as show below.
DISTINCT works fine on single selected fields. But in this case, the
SELECT statement has multiple fields. Is this the correct way to use
DISTINCT on multiple fields?

$qry = odbtp_query("SELECT DISTINCT WebGradStudents.IDNo AS studentID,
LastName, FirstName, WorkPhone, Email, Office, Curriculum, areaID,
qryOtherProjects.Extra FROM WebGradStudents LEFT OUTER JOIN
qryOtherProjects ON WebGradStudents.IDNo = qryOtherProjects.studentID
ORDER BY LastName");

Zhen, Don Construction 211-4321 zh***@some.edu 403 Bayon
Zhen, Don Construction 211-4321 zh***@some.edu 403 Bayon

I'd appreciate any help.

Bing

May 5 '06 #1
4 4359

<du****@gmail.com> schreef in bericht news:11*********************@y43g2000cwc.googlegro ups.com...
Hello everyone,

I've tried both DISTINCT or DISTINCTROW in the following query in a PHP
script. But the results still contain duplicate records as show below.

Zhen, Don Construction 211-4321 zh***@some.edu 403 Bayon
Zhen, Don Construction 211-4321 zh***@some.edu 403 Bayon


This is NOT similar data ... look carefully, (paste in Notepad if you don't see it here ...)

Arno R
May 5 '06 #2
Bri


du****@gmail.com wrote:
Hello everyone,

I've tried both DISTINCT or DISTINCTROW in the following query in a PHP
script. But the results still contain duplicate records as show below.
DISTINCT works fine on single selected fields. But in this case, the
SELECT statement has multiple fields. Is this the correct way to use
DISTINCT on multiple fields?

$qry = odbtp_query("SELECT DISTINCT WebGradStudents.IDNo AS studentID,
LastName, FirstName, WorkPhone, Email, Office, Curriculum, areaID,
qryOtherProjects.Extra FROM WebGradStudents LEFT OUTER JOIN
qryOtherProjects ON WebGradStudents.IDNo = qryOtherProjects.studentID
ORDER BY LastName");

Zhen, Don Construction 211-4321 zh***@some.edu 403 Bayon
Zhen, Don Construction 211-4321 zh***@some.edu 403 Bayon

I'd appreciate any help.

Bing


Is this happening to all records? Or is is just a few of them? If its
just a few of them, check the fields that appear to be displaying as
blank (it seems that you have more fields in the SELECT than you have in
the example records, so I'm guessing that they are blank in the table).
If Zero Length Strings are allowed on those fields, then a ZLS will
'look' the same as a Null in the display but are not the same as far as
Distinct is concerned. If that's not it, then it might help to show us
the data in the tables that correspond to the sample output so someone
can try to duplicate he problem.

--
Bri

May 5 '06 #3
Bri
Arno R wrote:
<du****@gmail.com> schreef in bericht news:11*********************@y43g2000cwc.googlegro ups.com...
Hello everyone,

I've tried both DISTINCT or DISTINCTROW in the following query in a PHP
script. But the results still contain duplicate records as show below.

Zhen, Don Construction 211-4321 zh***@some.edu 403 Bayon
Zhen, Don Construction 211-4321 zh***@some.edu 403 Bayon

This is NOT similar data ... look carefully, (paste in Notepad if you don't see it here ...)

Arno R


Hmm, while I was looking at this myself to help out the OP, I didn't see
this difference in his original (it all lined up visually). It showed up
in the text I quoted in my reply (but I didn't notice it until seeing
your post and going back to it). It must be tab delimited or something?

--
Bri

May 5 '06 #4

Bri wrote:
Arno R wrote:
<du****@gmail.com> schreef in bericht news:11*********************@y43g2000cwc.googlegro ups.com...
Hello everyone,

I've tried both DISTINCT or DISTINCTROW in the following query in a PHP
script. But the results still contain duplicate records as show below.

Zhen, Don Construction 211-4321 zh***@some.edu 403 Bayon
Zhen, Don Construction 211-4321 zh***@some.edu 403 Bayon

This is NOT similar data ... look carefully, (paste in Notepad if you don't see it here ...)

Arno R


Hmm, while I was looking at this myself to help out the OP, I didn't see
this difference in his original (it all lined up visually). It showed up
in the text I quoted in my reply (but I didn't notice it until seeing
your post and going back to it). It must be tab delimited or something?

--
Bri


Thanks all who replied. I've found out why now. There is nothing
wrong with either DISTINCT or DISTINCTROW. Indeed, there are more
fields in the SELECT than in what actually show up. The returned rows
are truly distinct like this:

Zhen, Don Construction 211-4321 zh***@some.edu 403 Bayon value2 blah
blah
Zhen, Don Construction 211-4321 zh***@some.edu 403 Bayon value1 blah
blah

The first several fields are identical and just what I needed to
display. That's what puzzled me. All is fine now.

Bing

May 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ben | last post by:
This is a PHP / MySQL kind of question. I am making a script which simply pulls information from a database and displays it on screen. BUT there will be entries where fields could be the same, and...
6
by: John M | last post by:
Hi, The line below is used to feed a combobox. (It is from a database which is used to log pupil behaviour!) The 'incidents' table contains a list of students who have been involved in incidents....
5
by: Fred Zuckerman | last post by:
Can someone explain the difference between these 2 queries? "Select Distinct id, account, lastname, firstname from table1" and "Select DistinctRow id, account, lastname, firstname from table1" ...
2
by: Jim H | last post by:
I am storing incoming data in memory using a DataTable. After I'm done retrieving the data I need to get the distinct rows. I tried using DataTable.Select but that doesn't work. If I have...
6
by: dick | last post by:
Am working with MS Access 2003 & tables downloaded from Oracle. Am not a GURU, more of a hacker, but have done a bit of everything in many languages/programs/etc. I have data fields in 2 tables...
6
by: issac | last post by:
Hi folks Im trying to do a simple query involving the distinct keyword and an access 2000 db, but have been frittering with it for amost and hour and a half and I cant make it work. This is...
2
by: johnhanis | last post by:
I'm using a Visual Basic front end with an SQL query to select some data from a MS Access database. I have a table named Tithes with Columns of TitheDate Tither No Total Tithes Faith Promise...
3
lwwhite
by: lwwhite | last post by:
I've got a a datasheet subform that gets its data from a SELECT DISTINCT query. The data is not editable. When I remove the DISTINCT qualifier from the query, the data is editable, but of course I...
1
by: ggfota | last post by:
Hi I have a problem with SELECT DISTINCT query. I'm trying to solve why it causes error 3464. Guess that problem might be cause by one field. The source table has text(17) field from which I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.