943,522 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 672
  • MySQL RSS
May 11th, 2009
0

Critical problem "Like"

Expand Post »
hi all Database Masters

Here i have suffer one critical issue,i have two column a and b,


Table name : Student
"A" "B"
"1" "SAntOsh"
"2" "SAuraV"
"3" "SAriya"
"4" "SAnju"
"5" "SAthiYa"


These are the sample records from my Table field. The "B" column always start with 'SA', the problem now in column B that has capital letter and I need to sort out all B that only has CAPITAL letter inside the letter and the out put will be displayed like this

A B
"1" "SAntOsh"
"2" "SAuraV"
"5" "SAthiYa"

Please help me out for this question

Thanks in Advance
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
saurav.prasad28 is offline Offline
11 posts
since Apr 2009
May 11th, 2009
0

Re: Critical problem "Like"

... I need to sort out all B that only has CAPITAL letter inside the letter and the out put will be displayed like this

A B
"1" "SAntOsh"
"2" "SAuraV"
"5" "SAthiYa"

Please help me out for this question

Thanks in Advance
You need a regular expression. Something like this will match rows that contain at least one capital letter in the remainder of the field:
MySQL Syntax (Toggle Plain Text)
  1. SELECT * FROM myTable WHERE myField REGEXP 'CAPS.*[A-z]';
Reputation Points: 51
Solved Threads: 35
Posting Whiz in Training
Fest3er is offline Offline
238 posts
since Aug 2007
May 11th, 2009
0

Re: Critical problem "Like"

Click to Expand / Collapse  Quote originally posted by Fest3er ...
You need a regular expression. Something like this will match rows that contain at least one capital letter in the remainder of the field:
MySQL Syntax (Toggle Plain Text)
  1. SELECT * FROM myTable WHERE myField REGEXP 'CAPS.*[A-z]';




hi Fest3er

Thanks for giving the reply

but when I try which querry you send me but it doesn't give the out put

sql Syntax (Toggle Plain Text)
  1. SELECT * FROM student WHERE b REGEXP 'CAPS.*[A-z]';

Please help me out.

thanks
Last edited by peter_budo; May 11th, 2009 at 7:01 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
saurav.prasad28 is offline Offline
11 posts
since Apr 2009
May 11th, 2009
1

Re: Critical problem "Like"

hi Fest3er

Thanks for giving the reply

but when I try which querry you send me but it doesn't give the out put

select * from student where b regexp 'CAPS.*[A-z]';

Please help me out.

thanks
You're quite right; it doesn't work, and wasn't supposed to work verbatim.

The regular expression needs to be a pattern that matches your data, not the fictitious data in my fictitious table. That bit of learning is left as an exercise for the student (you).
Reputation Points: 51
Solved Threads: 35
Posting Whiz in Training
Fest3er is offline Offline
238 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: Mysql Connector ODBC 3.51 on remote machine
Next Thread in MySQL Forum Timeline: Query 3 tables with a condition





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC