How come these commands give me " missing From clause"?!
select name,count(path) as num from authors join articles on author.id=articles.author join log on log.path=concat('/article/', articles.slug) group by authors.name order by num desc;
select title, count(path) as num from articles join authors on articles.author = authors.id join log on log.path = concat('/article/',articles.slug) group by title, path, authors.name order by num desc limit 3;
Here is my complete python code tho:
import psycopg2
db = psycopg2.connect(database="news")
c=db.cursor()
c.execute("""
select title, count(path) as num from articles join authors on articles.author = authors.id join log on log.path = concat('/article/',articles.slug) group by title, path, authors.name order by num desc limit 3;
""")
c.execute("""select name,count(path) as num from authors join articles on author.id=articles.author join log on log.path=concat('/article/', articles.slug) group by authors.name order by num desc;""")
rows=c.fetchall()
print (rows)
db.close
The error that shows is the following: psycopg2.errors.UndefinedTable: missing FROM-clause entry for table "authors" LINE 1: ...,count(path) as num from authors join articles on author.id=...
ONclause. Make sure it references authors. - Parfait