views:

143

answers:

3

i have an ms-access table

TableA

MSN   PR
11    -
13    A
12    Dead
14    B
15    C

How can i write an sql query to remove records in "-" and "Dead" occurances in PR collumn. so that query result should be

MSN  PR
13   A
14   B
15   C

any help appreciated

+4  A: 

To exclude the rows from a selection:

select *
from TableA
where PR not in ('-','Dead')

Or to permanently remove them:

delete
from TableA
where PR not in ('-','Dead')
Andomar
+1  A: 
select msn, pr from tableA where pr not in ('_', 'Dead')
Steve De Caux
A: 

The answer essentially is 'create a search condition by adding a WHERE clause to your query' i.e. you clearly know next to nothing about SQL so an online tutorial aimed a beginners would be more appropriate than a Q&A site.

onedaywhen
Seems like the Access QBE would be a good place to start learning, no?
David-W-Fenton
If it was, why is the OP asking?
onedaywhen
Maybe the OP is asking because they don't understand the power of the QBE, i.e., drag and drop for constructin your query and pure SQL view for understanding what's going on behind the QBE.
David-W-Fenton
I find elements of the Access UI more confusing than the SQL code it is writing for me. I guess I'm a coder rather than a visual learner. Who knows, maybe the OP is too? But yes, I agree that the QBE is one of the better ones because it does reveal the resulting SQL code for editing (better if it would always honour the edits!) But it tend to be the exception: the Relationships GUI is probably the worst, IMO, closely followed by the table designer. No way of getting the SQL DDL out of those.
onedaywhen