Linked Questions

2 votes
6 answers
7k views

Possible Duplicate: What's the difference between NOT EXISTS vs. NOT IN vs. LEFT JOIN WHERE IS NULL? I need to wite a query that will retrieve the records from Table A , provided that the key ...
user avatar
4 votes
1 answer
2k views

I'm trying to get the fastest performance for this DELETE (and SELECT) query. Is there a better way to DELETE the records, because this takes over 10 minutes to run? I imagine it has to do it's own ...
JustBeingHelpful's user avatar
0 votes
0 answers
59 views

Both of the following queries work perfectly for me at the moment giving out the same results. Which one of the following two are more preferable for huge databases in the long run? Or say, ...
Shreyansh Kashyap's user avatar
768 votes
16 answers
1.6m views

table1 (id, name) table2 (id, name) Query: SELECT name FROM table2 -- that are not in table1 already
z-boss's user avatar
  • 17.7k
2219 votes
2 answers
2.3m views

What's the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN in MySQL?
Lion King's user avatar
  • 34.1k
650 votes
11 answers
2.0m views

Which of these queries is the faster? NOT EXISTS: SELECT ProductID, ProductName FROM Northwind..Products p WHERE NOT EXISTS ( SELECT 1 FROM Northwind..[Order Details] od WHERE p....
ilitirit's user avatar
  • 16.4k
29 votes
4 answers
76k views

I have the following tables: Users Banned SELECT u.* FROM Users WHERE u.isActive = 1 AND u.status <> 'disabled' I don't want to include any rows where the user may also be in the ...
loyalflow's user avatar
  • 15.1k
12 votes
4 answers
33k views

Using MySQL 5.x I want to efficiently select all rows from table X where there is no related row in table Y satisfying some condition, e.g. Give me all records in X where a related Y with foo = bar ...
podperson's user avatar
  • 2,393
10 votes
5 answers
24k views

I want to run a mysql query to select all rows from a table films where the value of the title column does not exist anywhere in all the values of another column (collection). Here is a simplified ...
jessica's user avatar
  • 3,141
4 votes
2 answers
10k views

I want to delete all rows which has no existing foreign key in another table example: table1 +----+-------+ |id | data | +----+-------+ | 1 | hi | +----+-------+ | 2 | hi | +----+-------+ | ...
Lawrence Boadilla's user avatar
3 votes
3 answers
7k views

Let's say I have 2 tables (tb1, tb2) with both the following schema: CREATE TABLE tb1 ( col1 INT NOT NULL, col2 TEXT NOT NULL, col3 TEXT NOT NULL, col4 REAL ); How do I find records of tb1 ...
sober's user avatar
  • 121
4 votes
5 answers
6k views

Let's say I have two identical tables, A and B, with the row "x". I want to select all elements in A, where the value of x in A is not in any value of x of B. How do I do that?
TravisG's user avatar
  • 2,373
2 votes
2 answers
13k views

I'm optimizing some SQL queries (this could be considered part 2 of a question i recently posted) and replacing some NOT IN with NOT EXISTS predicates Am I right in thinking that the main benefit to ...
managedheap84's user avatar
1 vote
5 answers
5k views

I am using Microsoft SQL Server 2008 and we have two tables called Applications and Enrolments. I want to know which applications are not converted into the Enrolments. As shown in the following ...
TTCG's user avatar
  • 9,151
1 vote
4 answers
9k views

I have a complex query, but here is the essence of what I'm trying to do In a table looking like this: Col1 Col2 Bill 0 Bill 0 Bill 0 Bill 1 Bill 1 John 1 John 1 Jonh 1 The above ...
Sweetspot's user avatar

15 30 50 per page
1
2 3 4 5