PDA

Click to See Complete Forum and Search --> : Recordset without repeating


Tonatiuh
Mar 20th, 2000, 05:43 AM
These are two fields of more, of three records of my table (for example):

RECORD 1:
field1 = x
field2 = y

RECORD 2:
field1 = x
field2 = z

RECORD 3:
field1 = x
field2 = y

I want a recordset where field1 = x but, not repeat the value of field 2. This is, the recordset must have just two records, the record 1 and 2 (or 2 and 3).

I tryed this sql sentence:

SELECT * FROM table WHERE field1 = 'x'

But get 3 records.

What would be the correct sentence?

dlint
Mar 20th, 2000, 02:19 PM
You need to add a grouping statement to your SQL stmt. I used a table called Table 1, added the two fields and used the following SQL stmt to get the results you wanted. Hope this helps.

SELECT Table1.Field1, Table1.Field2
FROM Table1
GROUP BY Table1.Field1, Table1.Field2;

Elias
Mar 20th, 2000, 08:53 PM
or
"Select distinct field2"
"from table"
"where field1=x"

keep in mind that this recordset will only allow you to access field2, however, since you queried on field1, you already know that it is x!

-Elias