473,387 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Not clear about this query

select *From titles

(18 row(s) affected)

Totally 18 records are there in Titles table.

When I query

select title,title_id From titles where title like 'T%' and title_id
like 'M%'

It is returning 2 records.

So,now if I introduce a not in 2 places also it should return 16
records.
Whereas it is returning 14 records. What is the bestway to understand
this.

select title,title_id From titles where title not like 'T%' and
title_id not like 'M%'

Thanks
Ganesh
Jul 20 '05 #1
2 3443
Hi

You should get 16 records if you use an OR instead of the AND in the where
clause.

NOT ( A AND B )
NOT A OR NOT B

John

"Babu" <ba************@yahoo.com> wrote in message
news:bc*************************@posting.google.co m...
select *From titles

(18 row(s) affected)

Totally 18 records are there in Titles table.

When I query

select title,title_id From titles where title like 'T%' and title_id
like 'M%'

It is returning 2 records.

So,now if I introduce a not in 2 places also it should return 16
records.
Whereas it is returning 14 records. What is the bestway to understand
this.

select title,title_id From titles where title not like 'T%' and
title_id not like 'M%'

Thanks
Ganesh

Jul 20 '05 #2
ba************@yahoo.com (Babu) wrote in
news:bc*************************@posting.google.co m:
select *From titles

(18 row(s) affected)

Totally 18 records are there in Titles table.

When I query

select title,title_id From titles where title like 'T%' and title_id
like 'M%'

It is returning 2 records.

So,now if I introduce a not in 2 places also it should return 16
records.
Whereas it is returning 14 records. What is the bestway to understand
this.

select title,title_id From titles where title not like 'T%' and
title_id not like 'M%'

Thanks
Ganesh


Apparently two of your records satisfy one but not both of the LIKE
clauses; therefore they are not included in your latter statement.

.... where title like 'T%' and title_id like 'M%' : 2 records
.... where title not like 'T%' and title_id not like 'M%' : 14 records
.... where not (title like 'T%' and title_id like 'M%): 16 records
--
Ross Presser -- rpresser AT imtek DOT com
"... VB is essentially the modern equivalent of vulgar Latin in 13th
Centurary Europe. Understand it, and you can travel to places you never
heard of and still understand some people." -- Alex K. Angelopoulos
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Weeepie | last post by:
Hello, Is it possible to clear a datagrid in VBdotNET? I'm using a query to fill the datagrid, but when I change the parameter, the next query follows the previous. Is there someone who can...
3
by: Kyle Kolander | last post by:
I posted this in response to a previous thread but have not gotten any replies back... Hopefully someone has an answer? From looking at sections 27.7.3.2 and 27.7.1.2 of the standard, it appears...
4
by: Raterus | last post by:
Howdy, Simple question, but I can't figure out how to do it. I have a a page which is called initially with a querystring. After I get the querystring values, I don't need the querystring to...
7
by: stig | last post by:
hi. coming from postgresql, i am used to textual references to most of the things i do with the database. i feel a little lost with all the graphical. i have few questions regarding MS SQL 2000...
5
by: Michael C via AccessMonster.com | last post by:
Hello, I have a table that I am appending 3 seperate tables into. My main problem is that each time I append the data, it simply adds to the data already there. That might sound ok, except that...
4
by: traceable1 | last post by:
I am trying to improve the performance of a query. No matter how bad it runs the first time, it runs really fast the second time. So how can I tell if I've done anything to improve the query if...
0
by: Oliver Bleckmann | last post by:
hey guys, i have a little problem. my cgi routines are working so far, but i need to redirect to the cgi-programm and what the "posted" data to be cleared if redirected. i don't know how the post...
1
by: prabhu A | last post by:
I have a page which is called initially with a querystring. After I get the querystring values, I don't need the querystring to appear in the url anymore. How can I get rid of it? A postback...
4
by: rdubus | last post by:
After I have filled my datagridview I want to clear it up when the options for the query changes. I know how to clear the fields but I don't know how to clear the rows, so the datagridview appears...
5
by: plumba | last post by:
Ok, another query.... I have a checkbox at the bottom of my form which when checked unhides a <div> block which displays the submit button. The problem I have is when the clear form button is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.