Click here to Skip to main content
15,880,651 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hello,

I came across through below interesting question? What is the difference between:
SQL
select * from employee
and
SQL
select empid,empname,empcity,empsalary from employee

Thanks.
Posted
Updated 4-Sep-14 17:36pm
v2
Comments
Sergey Alexandrovich Kryukov 5-Sep-14 1:41am    
Incorrect question. The difference is: "first query has * in it". Or: "first query searches in all columns". Or "first query has two words". Which answer would you prefer? Questions about "difference" are most usually incorrect.
And why not simply reading elementary SQL textbook or reference?
—SA

This sounds a bit like a homework....

Anyhow, there are quite a few differences. To name some from the top of my head:
<lu>
  • the amount of columns is different

  • the order of the same columns returned may be different

  • the second one may fail because of wrongly typed column name

  • the second one may fail because of mixed case characters column names

  • the second one may use (different) index

  • the second may return the results without ever accessing the employee table at all

  • The amount of data transferred to the client may be different

As said this sounds a bit like homework, so at the moment I'll leave the justifications out from this answer :)
 
Share this answer
 
v2
Comments
CPallini 5-Sep-14 1:34am    
5.
Wendelius 5-Sep-14 4:39am    
Thanks :)
Sergey Alexandrovich Kryukov 5-Sep-14 1:43am    
I limited my response by a note that the "difference" question is incorrect. Indeed, what is "difference".
My 5 for spotting so many aspects. :-)
—SA
Wendelius 5-Sep-14 4:39am    
Thanks :)
kk2014 5-Sep-14 2:38am    
Hi Mika Wendelius,

the differences u said are the basic differences which I know. are there any other differences?

Thanks,
Say google first.. When you have an issue or doubt

Your solution is here.

Select * Vs Select Column Name[^]
 
Share this answer
 
Comments
CPallini 5-Sep-14 1:34am    
5.
thatraja 5-Sep-14 3:37am    
5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900