php - how to write this query in PDO? -
i had used query using mysql_query() , mysql_connect(), bun using pdo in php
please me, best , fastest way query:
my old query was:
$sql = "select * products publish = '1' , id in (select product_id category_controller category_id in (select id categories publish = '1'))"; $result = mysql_query($sql); my new query is:
$pdo = new pdo("mysql:host=localhost;dbname=mydb", 'root', ''); $sql = "select * products publish = '1' , id in (select product_id category_controller category_id in (select id categories publish = '1'))"; $result = $pdo->query($sql); but both ways had used beacuse there more 5000 records in products table.
please me find new , fastest way run query.
you may speed using join concept rather sub queries this.
select p.* products p join category_controller cc on cc.category_id = c.id join categories c on c.publish = 1 p.publish = 1
Comments
Post a Comment