2

Here is my query:

Does this look efficient? Is there an advantage of using JOIN? Or is this the same?

$query_Recordset2 = 
"SELECT cute_news.category, cute_news.id, cute_story.short, cute_story.post_id, cute_news.date, cute_news.url, cute_news.title 
FROM cute_news, cute_story 
WHERE cute_news.id = cute_story.post_id AND category LIKE '10%' 
ORDER BY date DESC LIMIT 0,35";
eberswine
  • 1,224
  • 3
  • 20
  • 39

3 Answers3

6

This question might be a duplicate of that one.

Implicit JOINs do not carry the intent, and are thus less readable.

Your query will lead to strictly same results as:

SELECT cute_news.category, cute_news.id, cute_story.short, cute_story.post_id, cute_news.date, cute_news.url, cute_news.title 
FROM cute_news
 INNER JOIN cute_story ON cute_story.post = cute_news.id
WHERE category LIKE '10%' 
ORDER BY date DESC LIMIT 0,35

but the latter query is far more readable because you separate JOIN predicates from filters and express the logic behind the query.

Community
  • 1
  • 1
Benoit
  • 76,634
  • 23
  • 210
  • 236
3

The "implicit join notation" simply lists the tables for joining (in the FROM clause of the SELECT statement), using commas to separate them. Thus, it specifies a cross join, and the WHERE clause may apply additional filter-predicates (which function comparably to the join-predicates in the explicit notation)

from wikipedia

In other words it's the same

Mansuro
  • 4,558
  • 4
  • 36
  • 76
2

If you mean the FROM clause having multiple tables, comma-separated, then yes, it is basically the same as an INNER JOIN.

However, this is old syntax; it is preferred to use INNER JOIN, which is more standard.

In addition, the problem with the old syntax is that by combining the joining fields with the rest of the WHERE clause, it can make the query hard to read, and in some cases cause extra work for the parser. It is much better to explicitly state the relationships in the ON clause for each JOIN.

dee-see
  • 23,668
  • 5
  • 58
  • 91
Spudley
  • 166,037
  • 39
  • 233
  • 307