472,143 Members | 1,146 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

To pull all emails that contains +,^,*,&,!

create table mail3(email varchar(50))
insert into mail3 values('mansi.sharma@yahoo.co.in')
insert into mail3 values('mansi.sharma+yahoo.co.in')
insert into mail3 values('mansi.sharma^yahoo.co.in')
insert into mail3 values('mansi.sharma*yahoo.co.in')
insert into mail3 values('mansi.sharma&yahoo.co.in')
insert into mail3 values('mansi.sharma!yahoo.co.in')
insert into mail3 values('mansi&sharma!yahoo.co.in')
select * from mail3

select * from mail3 where email like '%+%'
Above Query is wokimg fine for + sign.

But If I write the
select * from mail3 where email like '%+%' or '%*%'

Error is coming.Plz reply
Apr 10 '08 #1
6 1155
deepuv04
227 Expert 100+
create table mail3(email varchar(50))
insert into mail3 values('mansi.sharma@yahoo.co.in')
insert into mail3 values('mansi.sharma+yahoo.co.in')
insert into mail3 values('mansi.sharma^yahoo.co.in')
insert into mail3 values('mansi.sharma*yahoo.co.in')
insert into mail3 values('mansi.sharma&yahoo.co.in')
insert into mail3 values('mansi.sharma!yahoo.co.in')
insert into mail3 values('mansi&sharma!yahoo.co.in')
select * from mail3

select * from mail3 where email like '%+%'
Above Query is wokimg fine for + sign.

But If I write the
select * from mail3 where email like '%+%' or '%*%'

Error is coming.Plz reply
hi,
to pull the mail ids having the given symbols you can use the following query

Expand|Select|Wrap|Line Numbers
  1. select * from mail3 
  2. where email like '%+%' or email like '%*%' or
  3. email like '%^%' or email like '%&%'
  4.  
  5. or simply use the following query 
  6.  
  7. select * from mail3 
  8. where email not like '%@%'
  9.  
Apr 10 '08 #2
Thx,It worked.
Plz see the following query-

SELECT * FROM mail3
WHERE email NOT LIKE '%@%'
or email not like '%&%'


Instead of showing the particular records ,the above query is displaying all the records.
Apr 10 '08 #3
Thx,It worked.
Plz see the following query-

SELECT * FROM mail3
WHERE email NOT LIKE '%@%'
or email not like '%&%'


Instead of showing the particular records ,the above query is displaying all the records.
That's because of the OR. For the email with the "&" in it, the where evaluates like this:

email NOT LIKE '%@%' --> True
email NOT LIEK '%&%' ---> False
so you have
True OR False, which evaluates to True.

Put another way, every record in the table either doesn't have a "&" or it doesn't have a "@".
Apr 10 '08 #4
I didn't understand what r u trying to say.
Apr 10 '08 #5
ck9663
2,878 Expert 2GB
He's saying try to use AND instead of OR

-- CK
Apr 10 '08 #6
Thanks ck,
I Got it.
Apr 11 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by tconti | last post: by
1 post views Thread by Steven Bazeley | last post: by
12 posts views Thread by chadlupkes | last post: by
1 post views Thread by SpankyTClown | last post: by
3 posts views Thread by tangerine777 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.