If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > How to select titles begin with number

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-23-04, 13:48
thesandman thesandman is offline
Registered User
 
Join Date: Jul 2004
Posts: 6
How to select titles begin with number

I am trying to find a way to select any record that begins with numbers meaning
0-infinity.

I thought using between, but i would have to set the range, but would rather have it just see its a numeral and act accordingly.

Rich
Reply With Quote
  #2 (permalink)  
Old 10-23-04, 14:41
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
select foo from bar where qux regex '^[0-9]'
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 10-23-04, 16:32
thesandman thesandman is offline
Registered User
 
Join Date: Jul 2004
Posts: 6
OK,
How could i use this with my current select which is selecting anything LIKE $letter%.

I would like it to Select titles with either numbers or letters but not both.
Example:

SELECT * FROM movies WHERE title LIKE $letter% OR title LIKE regex [0-9]

This isnt the correct code, because I am not sure how to implement.
Thanks
Rich
Reply With Quote
  #4 (permalink)  
Old 10-23-04, 16:40
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by thesandman
I would like it to Select titles with either numbers or letters but not both.
could you please give some examples of titles that do not satisfy these criteria (either numbers or letters)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 10-23-04, 17:07
thesandman thesandman is offline
Registered User
 
Join Date: Jul 2004
Posts: 6
titles that begin with any letter of the alphabet:

An American Werewolf in London
The Thing
Salo

Any title that begins with numerals like:
500 Blows
1,001 ways to kill a cat

if you go to http://www.rareoopdvds.com/listing.php?letter=e
you will see what I am actually doing.

Thanks
Rich
Reply With Quote
  #6 (permalink)  
Old 10-23-04, 17:39
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
okay, i understand titles starting with letters

and i understand titles starting with numbers

what i was interested in seeing examples of was titles that satisfied what you said earlier - "I would like it to Select titles with either numbers or letters but not both"

titles that start with letters --
Code:
select foo from bar where qux regexp '^[[:alpha:]]'
titles that start with numbers --
Code:
select foo from bar where qux regexp '^[[:digit:]]'
titles that start with neither a letter nor a number --
Code:
select foo from bar where qux regexp '^[^[:alnum:]]'
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On