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

EASY question, query only cap. letters

Status
Not open for further replies.

upr

MIS
Oct 13, 1999
3
US
How do you create a query that will return only the capitalized entries?
 
SELECT your_select_list<br>
FROM your_table<br>
WHERE your_column = UPPER(your_column);<br>
<br>

 
carp,<br>
<br>
Can this code be used to change the contents of a column to all caps? If so, what is the update statement? If not, what is the code, please?<br>
<br>
Thanks.<br>
<br>
Bob
 
You bet!<br>
Try this:<br>
<br>
UPDATE your_table<br>
SET your_column = UPPER(your_column)<br>
WHERE your_column &lt;&gt; UPPER(your_column);<br>

 
try<br>
<br>
SELECT your_select_list<br>
FROM your_table<br>
WHERE your_column &gt;= 'A';<br>
<br>
That will pick up all rows starting with a capital letter.<br>
<br>
-ml<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= > </a><br>
 
I think Mike Lacey's code would prove better if dealing with large tables as, with some Relational Databases, functions like UPPER can create an additional overhead. <p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>
 
Without a doubt, Mike's query is far more efficient if you are looking for entries that begin with an upper case character - even more so if there is an index on the column!<br>
<br>
So it looks like the list of options is:<br>
<br>
Mike's query if you are only interested in the first character.<br>
<br>
My first query if you are interested in every character being upper case.<br>
<br>
Replace UPPER with INITCAP if you want just the first character in upper case and everything else in lower case.<br>
<br>
Replace UPPER with LOWER if you waant to find entries where all characters are lower case.<br>
<br>
Mike's approach will make use of any available indexes. Using UPPER, LOWER, or INITCAP will result in a full table scan.
 
Silly me, you are totaly right. <p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>
 
efficient queries are the only kind I write! <p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top