Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select I need to understand
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01496256
Message ID:
01496258
Views:
53
You are right. I completely missed that I need to include another criteria in the JOIN or in the WHERE. Thank you.

>The result is impossible for the query and data you posted.
>Most likely there're multiple records with PK=230 in one of tables or both.
>
>>
>>I am having a tough time understanding why the following query returns 6 rows for the PK_FLD = 230? Here are the two tables:
>>
>>Table A
>>PK_FLD ID_NAME
>>230 ABC
>>510 ABC
>>511 ABC
>>512 ABC
>>
>>TableB
>>PK_FLD
>>230
>>510
>>512
>>511
>>722
>>
>>
>>select TABLEA.PK_FLD FROM TABLEA JOIN TABLEB ON TABLEA.PK_FLD = TABLEB.PK_FLD
>>WHERE TABLEA.ID_NUMBER = "ABC"
>>
>>
>>I thought that the resulting query should have 4 rows but what is returned is:
>>230
>>230
>>230
>>230
>>230
>>230
>>510
>>511
>>512
>>
>>Could someone explain why? TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform