General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
>>>>>>I am trying to select distinct records from a sql statement in vfp.
>>>>>>But the distinct keyword only works on the whole record.
>>>>>>My question is there a way to limit records by a distinct column in vfp6.0? Thanks Eric
>>>>>
>>>>>The DISTINCT predicate does work on columns. Can you post the SQL statement that is giving you trouble?
>>>>
>>>>I have a persons table and a address table. The address table can have multiple
>>>>records for a particular person. The code goes as follows:
>>>>
>>>>SELECT DISTINCT PERSONS.ID, ADDRESS.STREET, ADDRESS.CITY, ADDRESS.STATE,; ADDRESS.ZIP FROM PERSONS, ADDRESS ;
>>>>WHERE PERSONS.ID = ADDRESS.ID ;
>>>>INTO TABLE Q1
>>>
>>>Sorry, but I was incorrect about the DISTINCT predicate, as you probably already know :). Are you trying to get just one address for each person? Or are you trying to get all people with more than one address?
>>
>>I am trying just to grab a person with a address, but I get several records for a person with several address records. I generally have to create a index on the id unique and that works fine.
>How do you decide which adress to use if there are multiple addresses?
I have a Address type field, I have gone back and have added the group by clause which seems to do the trick.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only