Select fields containing at least one non-space alphanumeric character
(Sorry I know this is an old chestnut; I have found similar answers here but not an exact answer)
I frequently hand type this kind of query from a console so I am always looking for easier to type solutions
SELECT *
FROM tbl_loyalty_card
WHERE CUSTOMER_ID REGEXP "[0-9A-Z]"; -- exact but tedious to type
or
SELECT *
FROM tbl_loyalty_card
WHERE LENGTH(CUSTOMER_ID) >0; -- could match spaces
Do you have anything 开发者_StackOverflowquicker to type even/especially if it's QAD?
Shorter, but will match any non-space, not just alphanumeric.
SELECT * FROM tbl_loyalty_card WHERE TRIM(CUSTOMER_ID) != '';
This is already pretty short; what I mean you are looking to gain at most something like 15% (10 chars out of 70).
If it is the speed and convenience you are after then I have a hunch that maybe one of these options might be better for you:
- script it (stored procedure, shell script)
- use keyboard macros
- start building the application to automate your tasks
A combination of LENGTH and TRIM should work better:
SELECT *
FROM tbl_loyalty_card
WHERE LENGTH(TRIM(CUSTOMER_ID)) >0;
精彩评论