Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How come SELECT DISTINCT SQL is not working?
Message
De
29/07/2002 18:27:15
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00683743
Message ID:
00683751
Vues:
29
This message has been marked as the solution to the initial question of the thread.
Steve,

SUSAN, TED, and WILLIAM are >= "ST", so those results are being returned. You can use the LIKE clause. Here is an example:
select * from bcmaster where name_first like "ST%"
I took a quick stab at modifying pcCondition to do this below...

>I have a search form with multiple textboxes so one may search on first name or last name or phone number or address and so on. Following is an example of how I build the First Name search command. I have never tried using a substitution macro in the middle of a SELECT. The command is half-working. It finds 4 first name records when I search on ST for STEVE. It finds me and SUSAN and TED and WILLIAM. But I don't see why it repeats STEVE for 30 records and SUSAN for 30 records and TED and WILLIAM also for 30 records. Only one of the STEVE records is correct the rest are bits and pieces of other records where first name is not STEVE. Here's my code. Can anyone tell me what I am doing wrong? I see the problem when I browse, but I don't see how to fix it. Do you? Thanks!
>
>
>	IF NOT EMPTY(firname)	&& First Name
>		pcCondition = pcCondition + "bcmaster.name_first like '" + alltrim(firname) + "%' AND "
>	ENDIF
>
>	IF NOT EMPTY(pcCondition)
>		pcCondition = LEFT(pcCondition, LEN(pcCondition)-5)
>		SELECT DISTINCT bcmaster.patid, bcmaster.name_last, bcmaster.name_first, ;
>			bcmaster.address1, bcmaster.area_code, bcmaster.phone, bcmaster.sex, ;
>			patient.socsecno, patient.drivers, patient.cartag1, patient.cartag2, ;
>			patient.eye, patient.bit1, patient.bil1, patient.bit2, patient.bil2 ;
>			FROM bcmaster, patient WHERE &pcCondition INTO CURSOR temp_recs
>
>		SELECT temp_recs
>		browse
>
>
Steve Gibson
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform