tags:

views:

65

answers:

3

(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 quicker to type even/especially if it's QAD?

A: 

Shorter, but will match any non-space, not just alphanumeric.

SELECT * FROM  tbl_loyalty_card  WHERE TRIM(CUSTOMER_ID) != '';
Andy
A: 

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
Unreason
Good idea, I will add another keyboard macro
zzapper
Thanks. Feel free to mark the answer as useful (for accepted answer as well). http://stackoverflow.com/faq
Unreason
A: 

A combination of LENGTH and TRIM should work better:

SELECT *
FROM tbl_loyalty_card
WHERE LENGTH(TRIM(CUSTOMER_ID)) >0;

Lost in Alabama