Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Mysql - Select column values from two tables and column count from other table

I have three tables zones, websites, webstats, I want to get website details and zones details from website and zones table respectevily and web impression from table webstats and order results by webstats impressions in DESC order. How i can do this.

My current query is

$onee="1";
$null="";
$link = new PDO("mysql:host=$host;dbname=$db", $username, $password, $options);
$stmt = $link->prepare("SELECT *.websites, (select count(*) from webstats where pubadhash=$null GROUP BY zoneweb) impress, from websites, webstats, zonez WHERE pubverify= ? ORDER BY FIELD(featured, 'yes') DESC LIMIT $items_per_page OFFSET $offset");
$stmt->execute([$onee]);
$result = $stmt->fetchAll();

$row_count = $stmt->rowCount();  

How to do this?

Comments