What is the difference between two queries:
1. SELECT * FROM table WHERE 1=1;
2. SELECT * FROM table

Answers were Sorted based on User's Feedback



What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM tab..

Answer / rajiv rohilla

No Diffrence at all

Is This Answer Correct ?    57 Yes 11 No

What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM tab..

Answer / malathi

Both the Queries will return the same ouput.
That means it will return all the rows that are available
in the table.

Is This Answer Correct ?    45 Yes 3 No

What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM tab..

Answer / g.nageswara rao

in first query 1=1 always true,then it retrives all columns
in a table.
so,there is no difference in between these two

Is This Answer Correct ?    39 Yes 3 No

What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM tab..

Answer / skumar

Both are returns the SAME results.

I dont know the meaning of the
SELECT * FROM Table_Name WHERE 1=1
SELECT * FROM Table_Name WHERE 2=2
SELECT * FROM Table_Name WHERE 5=5
SELECT * FROM Table_Name WHERE 100=100
.
.
.
etc..,

It accepts the where both are equal.

If you give like

SELECT * FROM Table_Name WHERE 100=1001
It is not accept.

Is This Answer Correct ?    34 Yes 1 No

What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM tab..

Answer / vijay

There is No Difference between these two

Is This Answer Correct ?    35 Yes 3 No

What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM tab..

Answer / krishna sandeep

Of course, both the Queries will get you the same data but,

When compared to the first case processing time will be
slightly reduced in the second case.

Bytes sent from client and Bytes received from server will
be more in the first case.

and one more thing is better not using "select * from ..."

Is This Answer Correct ?    17 Yes 0 No

What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM tab..

Answer / pavan

hey! I too agree there wont be any difference in result it
displays but the performance will be different. While
executing the first query the where condition to be checked
for each record it displays hence it takes much time to
execute while compared with question no 2 i.e, without
where condition. this is what I believe in.

Is This Answer Correct ?    14 Yes 2 No

What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM tab..

Answer / hasan

Both are same .
They r showing all results.

Is This Answer Correct ?    9 Yes 1 No

What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM tab..

Answer / naren

No difference

Is This Answer Correct ?    8 Yes 0 No

What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM tab..

Answer / akbar ali

The first query satisfies the condition true condition.

both are similar but not same. performance based querys ...

Is This Answer Correct ?    8 Yes 1 No

Post New Answer

More SQL Server Interview Questions

If we use where clause in the left outer join then how the query would behave/act?

1 Answers  


What is a scheduled job or what is a scheduled task?

0 Answers  


Disadvantages of the indexes?

0 Answers  


Your sql server is running out of disk space. You notice that there are several large files with ldf extensions what are these files?

0 Answers  


What is bit datatype and what's the information that can be stored inside a bit column?

1 Answers  






Explain the architecture of SQL Server?

2 Answers   ABC, HP, Oracle,


How to rebuild master databse?

0 Answers  


Is SET a SQL Keyword?

4 Answers   BitWise,


What is a derived table?

0 Answers  


A left outer join B B right outer join A gives the same result then what is the use of two?

1 Answers  


Do you know what is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure?

0 Answers  


What is set nocount on and what is set nocount off?

0 Answers  


Categories