-2

Transform following SQL query to Joins based query

SELECT * 
FROM STUDENTS 
WHERE StudentID IN (
  SELECT UserID FROM Stripe_Transactions where Quantity > 5
)

Since it is taking a long time to process!

Why does sub-query take long time?

axnet
  • 5,146
  • 3
  • 25
  • 45
  • Show output of `show create table STUDENTS` and `show create table Stripe_Transactions` and `explain SELECT * FROM STUDENTS WHERE StudentID IN (SELECT UserID FROM Stripe_Transactions where Quantity > 5)` – ysth Aug 17 '20 at 05:24
  • https://stackoverflow.com/questions/2577174/join-vs-sub-query – kmoser Aug 17 '20 at 05:25
  • 1
    Changing to join form may not make any difference – ysth Aug 17 '20 at 05:26

1 Answers1

0

SELECT tb1.* from STUDENTS tbl1 INNER JOIN Stripe_Transactions tbl2 on tbl1.StudentID=tbl2.UserID where tbl2.Quantity > 5