Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ordering items in an sql statement

Status
Not open for further replies.

estellemorris

Programmer
May 10, 2006
11
0
0
GB
Hi,

I am trying to order items, task 1, task 2, task 20, task 3 in my database using the order by function in my sql statement unfortunatly it orders it as task 1, task 2, task 20, task 3 not task 1, task 2, task 3, task 20 as I want it to. I believe that you cannot use the replace function within an sql statement unless you are using it directly within Access, any other idea?
 
Perhaps this ?
ORDER BY Val(Mid([field name],6))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
If the field in question is always of the form

task xx​

with the numeric part starting in the sixth character position then

Code:
ORDER BY Val(Mid([TheField],6))
 
thought abut that or using right(thefield, 6) but unfortunatly it doesn't work as I am also using distinct in ym sql statement
 
Well

Right('Task 23',6) will produce ask 23

You don't want the rightmost 6 characters ... you want the characters starting with the sixth one to the end of the string. That's why PHV and I suggested the Mid function.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top