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
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 |
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 |
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 |
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 |
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 |
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 |
Tell me what is the difference between locking and multi-versioning?
What is data file in computer?
how would you write a sql query to compute a frequency table of a certain attribute involving two joins? What changes would you need to make if you want to order by or group by some attribute? What would you do to account for nulls?
Can you create UNIQUE and PRIMARY KEY constraints on computed columns in SQL Server 2000?
What is raiseerror? What is raiseerror?
Why do we use trigger?
What Is Rdbms?
Sql studio em braces a variety of capabilities, but will I need them all? Is there a simpler product ? : sql server management studio
Lets say due to N/W or Security issues client is not able to connect to server or vice versa. How do you troubleshoot?
what are questions asked in TCS for database tester (sqlserver)for 2-3 exp?
Can foreign key be deleted?
Can we use Truncate command on a table which is referenced by FOREIGN KEY?