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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL phrase required for beginning and end of field

Status
Not open for further replies.

ozgirl

IS-IT--Management
Oct 15, 2003
8
AU
Hello,
I need to search on our bouquet code field for everything beginning with W and ending with 2, examples of what may be in the field are:WWH2, WTAB2, WNUTPAC2 (ie: varying lengths)

Can you please provide me with the sql so I can include it in my following program:

USE fforder
REPLACE ALL RECALL WITH {28.11.2003} FOR fforder.delivery >= {22.12.2003};
AND fforder.delivery <= {02.01.2004};
AND fforder.desp_ctry = &quot;0&quot;;
AND fforder.bqt_type = [?????code requested];

Looking forward to hearing back - I know it's something simple but I don't know what it is??
Thank you
Katie
 
Here is the select command. It should provide you with the info you're looking for.

SELECT field1, field2 FROM tablename WHERE LEFT(fieldname,1) = &quot;W&quot; AND RIGHT(ALLTRIM(fieldname),1) = &quot;2&quot;

Jim Osieczonek
Delta Business Group, LLC
 
Thanks heaps - it works!!
Katie
 
Sorry - first part worked - now I need to update this selection by replacing a field with another date and it's saying cannot update the cursor


USE fforder
SELECT order_no, recall, bqt_type FROM fforder WHERE LEFT(bqt_type,1) = &quot;W&quot; AND RIGHT(ALLTRIM(bqt_type),1) = &quot;2&quot;;
and delivery={25.12.2003}

REPLACE RECALL WITH {28.11.2003}

Many thanks again
Katie
 
My 1st post probably confused you. The SELECT statement sends the data, by default, to a read-only cursor.

REPLACE ALL RECALL WITH {28.11.2003} FOR fforder.delivery >= {22.12.2003};
AND fforder.delivery <= {02.01.2004};
AND fforder.desp_ctry = &quot;0&quot;;
AND fforder.bqt_type = [?????code requested];
AND LEFT(fieldname,1) = &quot;W&quot; AND RIGHT(ALLTRIM(fieldname),1) = &quot;2&quot;



Again, change fieldname to your &quot;real&quot; fieldname.

Jim Osieczonek
Delta Business Group, LLC
 
Katie,

Assuming you're send your results into a cursor, you need to add a READWRITE clause to the end of your SQL command.
Code:
SELECT field1, field2 FROM tablename WHERE LEFT(fieldname,1) = &quot;W&quot; AND RIGHT(ALLTRIM(fieldname),1) = &quot;2&quot; into cursor MyCursor READWRITE



-BP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top