Skip to main content
added 13 characters in body
Source Link
Shaulinator
  • 3.2k
  • 1
  • 13
  • 25

Aliasing your table helps for keeping joins straight in your head. (The t and a as seen below) Inner join only returns where results match, similar function to where in.

SELECT T.* FROM topics t
INNER JOIN
(
 SELECT DISTINCT(topic) 
 FROM answers
 ORDER BY date LIMIT 500
) a
ON t.topic_id = a.topic

Aliasing your table helps for keeping joins straight in your head. (The t and a as seen below) Inner join only returns where results match, similar function to where in.

SELECT * FROM topics t
INNER JOIN
(
 SELECT topic
 FROM answers
 ORDER BY date LIMIT 500
) a
ON t.topic_id = a.topic

Aliasing your table helps for keeping joins straight in your head. (The t and a as seen below) Inner join only returns where results match, similar function to where in.

SELECT T.* FROM topics t
INNER JOIN
(
 SELECT DISTINCT(topic) 
 FROM answers
 ORDER BY date LIMIT 500
) a
ON t.topic_id = a.topic
added 45 characters in body
Source Link
Shaulinator
  • 3.2k
  • 1
  • 13
  • 25

Aliasing your table helps for keeping joins straight in your head. (The t and a as seen below) Inner join only returns where results match, similar function to where in.

SELECT * FROM topics t
INNER JOIN
(
 answersSELECT atopic
on t.topic_id =FROM a.topicanswers
 ORDER BY date LIMIT 500
) a
ON t.topic_id = a.topic

Aliasing your table helps for keeping joins straight in your head. (The t and a as seen below) Inner join only returns where results match, similar function to where in.

SELECT * FROM topics t
INNER JOIN answers a
on t.topic_id = a.topic
ORDER BY date LIMIT 500

Aliasing your table helps for keeping joins straight in your head. (The t and a as seen below) Inner join only returns where results match, similar function to where in.

SELECT * FROM topics t
INNER JOIN
(
 SELECT topic
 FROM answers
 ORDER BY date LIMIT 500
) a
ON t.topic_id = a.topic
Post Undeleted by Shaulinator
Post Deleted by Shaulinator
Source Link
Shaulinator
  • 3.2k
  • 1
  • 13
  • 25

Aliasing your table helps for keeping joins straight in your head. (The t and a as seen below) Inner join only returns where results match, similar function to where in.

SELECT * FROM topics t
INNER JOIN answers a
on t.topic_id = a.topic
ORDER BY date LIMIT 500