Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL-Select from VFP table
Message
From
08/01/2007 08:11:44
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01183357
Message ID:
01183396
Views:
14
>Here's an unusual question (or at least this seems unusual to me):
>
>I have a VFP table that contains (among other things) a character field containing the values 0-50 as well as the values A-Z.
>
>In this client's data, A-Z represents quantifiable values less than zero, even though this field is a character field in the table.
>
>Assuming the table name is "mytable" and the character field I am referring to is named "myfield", If I wanted to select all records where myfield contains a "value" less than "D" for example, how would I do so? I can't change the structure of the table, etc (tons of legacy data) and if I run a select statement such as:
>
>Select * from mytable where myfield < "2"
>
>then I obviously get records back where myfield = "12", "19", etc (since the data is stored as a character, "12" is seen as less than "2", etc). Using VAL() on the field in advance doesn't work as part of the SQL-Select statement.
>
>Any suggestions on a quick solution? My hands are tied on how the data in this field is stored.
>
>Thanks,
tcSearch = 'D'

SELECT * from myTable ;
 WHERE IIF( ISDIGIT(m.tcSearch), ;
  ISDIGIT(myField) AND VAL(myField) < VAL(m.tcSearch), ;
  !ISDIGIT(myField) AND myField < m.tcSearch )
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform