I wonder what is the difference of these two queries and which one hás the best performance?  SELECT employee.*, company.name  FROM  company, employee WHERE employee.company_id = company.id AND company.id = '365'   or  SELECT employee.*, company.name  FROM  company  INNER JOIN employee ON employee.company_id  = company.id WHERE company.id = '365'
15299
Is there any efficiency difference in an explicit vs implicit inner join? For example:  SELECT * FROM table a INNER JOIN table b ON a.id = b.id;   vs.  SELECT a.*, b.* FROM table a, table b WHERE a.id = b.id;
12650
I seem to remember that (on Oracle) there is a difference between uttering select count(*) from any_table and select count(any_non_null_column) from any_table.  What are the differences between these two statements, if any?
86274
Here's a scenario:  Someone asked about "How to build a SQL query to get count and blah blah blah..."  His only tag is . I added the  and  tags to it.  Someone else answered with a nice SQL statement that has a "group by" statement which seems "logically inevitable".  I proceed to add a tag . I did that on the basis that someone who searches for  will be able to find this post useful, just as I did. My concern is, it wasn't described at all in the question, nor was it implied, unlike  and .  What is the community opinion?  The scenario above is a real one . And the one who answered it nicely is Jon Skeet.
17653
Some of code I read in trigger is like this    for(account a: [select id  from account where id in: mapAccount.keySet()]) {     //code      }    some are like   List&lt;Account&gt; listAccount = [select id  from account where id in: mapAccount.keySet()];   for(Account a: listAccount ){   //coode   }   Are those same from performance view?which one is better?
102447
Is there a best practice between using a LEFT JOIN or a NOT EXISTS format?  What is benefit to using one over the other?  If none, which should be preferred?  SELECT * FROM tableA A LEFT JOIN tableB B      ON A.idx = B.idx WHERE B.idx IS NULL     SELECT * FROM tableA A WHERE NOT EXISTS (SELECT idx FROM tableB B WHERE B.idx = A.idx)   I am using queries within Access against a SQL Server database.
25968
I want to know what is the difference between a query and a view in terms of performance. And if a view is costly, what else besides a query could I do to improve performance?
8207
What is the difference between the EXISTS and IN clause in SQL?  When should we use EXISTS, and when should we use IN?
108409
When I write a query like this...  select * from table1 t1 join table2 t2 on t1.id = t2.id   Does the SQL optimizer, not sure if that is the correct term, translate that to...  select * from table1 t1, table2 t2 where t1.id = t2.id   Essentially, is the Join statement in SQL Server just an easier way to write sql? Or is it actually used at run-time?  Edit: I almost always, and will almost always, use the Join syntax. I am just curious what happens.
8188
Just looking at:   (Source: )  What does this SQL do:  Robert'); DROP TABLE STUDENTS; --   I know both ' and -- are for comments, but doesn't the word DROP get commented as well since it is part of the same line?
42749
If i run below query it returns all records of that object:  Select ID, name from Contact where Name like '%%%'   This should return only those records which have % in the name. For example if i run below query it will return only those records which have test in the name.  Select ID, name from Contact where Name like '%test%'   Any idea, What is going on here?
5162
Using SQL Server - which is the fastest or best practice method to use for date retrieval? Is there a difference?
1681
When using SQL, are there any benefits of using = in a WHERE clause instead of LIKE?  Without any special operators, LIKE and = are the same, right?
87778
I have two tables that are joined together.   A has many B  Normally you would do:   select * from a,b where b.a_id = a.id   To get all of the records from a that has a record in b.   How do I get just the records in a that does not have anything in b?
84603
Say I have an ID row (int) in a database set as the primary key. If I query off the ID often do I also need to index it? Or does it being a primary key mean it's already indexed?  Reason I ask is because in MS SQL Server I can create an index on this ID, which as I stated is my primary key.  Edit: an additional question - will it do any harm to additionally index the primary key?
58842
Scenario:  Let's say I have two tables, TableA and TableB.  TableB's primary key is a single column (BId), and is a foreign key column in TableA.  In my situation, I want to remove all rows in TableA that are linked with specific rows in TableB: Can I do that through joins? Delete all rows that are pulled in from the joins?  DELETE FROM TableA  FROM    TableA a    INNER JOIN TableB b       ON b.BId = a.BId       AND [my filter condition]   Or am I forced to do this:  DELETE FROM TableA WHERE    BId IN (SELECT BId FROM TableB WHERE [my filter condition])   The reason I ask is it seems to me that the first option would be much more effecient when dealing with larger tables.  Thanks!
48161
I am not very familiar with databases and the theories behind how they work.  Is it any slower from a performance standpoint (inserting/updating/querying) to use Strings for Primary Keys than integers?
2523
After reading it, this is not a duplicate of . The answer may be related (or even the same) but the question is different.    What is the difference and what should go in each?  If I understand the theory correctly, the query optimizer should be able to use both interchangeably.