Ad

Every Derived Table Must Have Its Own Alias In C:\xampp\htdocs\company-directory\home.php

- 1 answer

I am facing this error, please help.thanks in advance

SELECT companies.company_name
FROM (SELECT companies.company_name FROM companies
WHERE companies.profile_progress BETWEEN 80 AND 100)
ORDER BY RAND() LIMIT 10

Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1248 Every derived table must have its own alias in C:\xampp\htdocs\company-directory\home.php:10 Stack trace: #0 C:\xampp\htdocs\company-directory\home.php(10): PDOStatement->execute() #1 {main} thrown in C:\xampp\htdocs\company-directory\home.php on line 10

Ad

Answer

You can use this code. I think it should work:

SELECT a.company_name FROM 
(SELECT companies.company_name 
FROM companies WHERE  companies.profile_progress 
BETWEEN 80 AND 100) a ORDER BY  RAND() LIMIT 10
Ad
source: stackoverflow.com
Ad