Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How come SELECT DISTINCT SQL is not working?
Message
From
29/07/2002 18:27:15
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00683743
Message ID:
00683751
Views:
30
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform