Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Qurery to get specific codes
Message
From
05/12/2017 09:08:47
 
 
To
04/12/2017 04:58:55
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01656093
Message ID:
01656139
Views:
55
>Dear Sir,
>
>Table1 has sno field varchar(70) and has this data
>
>
>1
>14
>1401
>1401001
>4
>41
>4101
>4101001
>4101002
>4101003
>4101020
>4101021
>4101022
>4102
>4102001
>4102002
>4102003
>4102020
>4102021
>45
>4501
>4501001
>4501002
>4501020
>4501021
>
>
>Now I want to get these codes only
>4101
>4101021
>4101022
>4102
>4102021
>
>Explanation:
>code between 4101020 and 4101050 alongiwth root code 4101
>code between 4102020 and 4102050 alongiwth root code 4102
>Do not want get any code that is greater that 4102099
>
>what query should I use?


select * from Table1 where between (val(left(field,4)), 4101, 4102) into cursor t_results

or

select * from Table1 where left(field,4) IN ("4101", "4102") into cursor t_results

should work for the example data, further filter for val(field)< 4102100 (or val(right(field,3))< 100) if question was imprecise) can be added
Previous
Reply
Map
View

Click here to load this message in the networking platform