tags:

views:

36

answers:

2

here is my code:

select column1, column2 from table1;

here is a preview of column1:

1.1 Specimen Mislabeled
1.9 QNS- Specimen Spilled in transit
1.3 QNS-Quantity Not Sufficient
1.6 Test Requisition Missing
1.11 Other - Validity only
1.11 Other-reject per practice
1.5 Patient Info. entered Incorrectly
1.11 Other-Validity
1.11 Other-validity only
1.11 Other-Reject per agency
1.11 Other - not our req
1.11 Other - Not ML requisition
1.11 Other - Defective POC cups?

i would like it to return only 1.11 Other when it sees anything like "*1.11 Other*"

another words i would like the result of the sql statement to be:

1.1 Specimen Mislabeled
1.9 QNS- Specimen Spilled in transit
1.3 QNS-Quantity Not Sufficient
1.6 Test Requisition Missing
1.11 Other
1.11 Other
1.5 Patient Info. entered Incorrectly
1.11 Other
1.11 Other
1.11 Other
1.11 Other
1.11 Other
1.11 Other

how do i do this?

+1  A: 
select column1 from table1 where column1 like '1.11 Other*'

It might be % instead of * I get those mixed up between sql and access. But I think it is *. Though if this doesn't work try %. Basically you are using a wildcard for the end so match the beginning and anything starting at the wildcard.

spinon
The function that you want to use is LIKE. That does a wildcard match where ever it sees the wildcard. If you want to do like you had in your comments then you would add a wildcard to the front of the string as well.
spinon
This solution won't return any rows that don't start with '1.11 Other'
Jim B
This solution won't return any rows that don't start with '1.11 Other'
i am a girl
I'm sorry I misread what they were looking for. You're right. What you said is right in your answer.
spinon
+1 for offering to help
i am a girl
Thanks user29823498750932874509823745!
spinon
Whether you use * or % for the wildcard in Access depends on whether you have Access set to "SQL 92" mode (then you use %) or use ALIKE in place of LIKE (then you can use either) or if you're using ADO (then you use %) or if you're using DAO (then you use %). Likewise, a passthrough to SQL Server (or any other database that uses %) will use %.
David-W-Fenton
+2  A: 

Use a CASE Statement; i.e.

SELECT 
  CASE WHEN Column1 LIKE '%1.11 Other%' 
     THEN '1.11 Other' 
     ELSE Column1 END AS Column1,
  Column2
FROM
   table1
Jim B
can you show me how i would incorporate that into my sql statement
i am a girl
updated to have the full query.
Jim B
thank you very much, do you know if this will work with access? i am getting an error
i am a girl
what's the error?
Jim B
syntax error (missing operator_) in query experssion 'CASE WHEN [Lab Occurrence Form].[1 0 Preanalytical (Before Testing)] LIKE '*1.11 Other*' THEN '1.11 Other' ELSE [Lab Occurrence Form].[1 0 Preanalytical (Before Testing)] END'.
i am a girl
ok; access is a little different. Use * instead of % to start. It also doesn't support CASE statements; use IIF instead. so, something like this should work: SELECT IIF(Column1 LIKE '*1.11 Other*', '1.11 Other', Column1) AS Column1
Jim B
thank you very much, here is my next question http://pastebin.com/72UkDw0S
i am a girl
Use your IIF statement all the way through your group by and having clauses
Jim B
here this is easier http://stackoverflow.com/questions/3152253/access-iif-statement-and-count
i am a girl
im sorry can u post the answer on the second link
i am a girl
You cannot use Case statements in ms-access SQL
Remou