Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select
Message
 
 
To
10/07/2012 09:28:01
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01547863
Message ID:
01548015
Views:
41
>>Hi,
>>
>>I have a case where I need to select records when one of three integer fields equals to some set value. For example, say table has fields Fld1 (Int), Fld2 (int), Fld3 (int). I want to find all records where a one of the fields has value nNumber. So the way I could do it as:
>>
>>
>>select * from MyTable where Fld1 = nNumber or Fld2 = nNumber or Fld3 = nNumber
>>
>>
>>Is there a faster approach that would hopefully work in both VFP and SQL Server? Note that the table has an index on Fld1, and Fld2, and Fld3.
>>
>>TIA.
>
>One thing that comes to mind is that, if you have three fields with the same type of information, you might be better off storing the information in a single field, and in separate records (perhaps in another table). This is basic data normalization, but of course, I don't know exactly what information your fields hold.

You are right, in general, that this situation would be better off normalized. But my case is very simple. The number of records in the table where there are these three integer field will be, maybe in 100s. Or even few. And at most will probably go to 1000 records. So to simplify, I keep them all in one table.
Thank you.
"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
Reply
Map
View

Click here to load this message in the networking platform