друзья и друзя друзей и похожие рекомендуемые товары
$product_related_data = array();
$sql="SELECT * , IF(tid='" .
(int)$product_id . "',pid,tid) AS related_id FROM "
. DB_PREFIX . "related
WHERE pid = '" . (int)$product_id . "' || tid = '".(int)$product_id."'
|| pid = ( SELECT pid FROM cannes_related WHERE tid = '".(int)$product_id."' LIMIT 1)
|| tid = ( SELECT pid FROM cannes_related WHERE tid = '".(int)$product_id."' LIMIT 1)
|| pid = ( SELECT tid FROM cannes_related WHERE pid = '".(int)$product_id."' LIMIT 1)
|| tid = ( SELECT tid FROM cannes_related WHERE pid = '".(int)$product_id."' LIMIT 1)
SELECT
SQL_CALC_FOUND_ROWS
f.id,
u.uid AS uid,
f.status as status,
IF(f.tid=:uid,1,0) As who
FROM ` friends` f
LEFT JOIN ` user` u ON (u.uid=IF(f.tid=:uid,f.uid,f.tid) )
LEFT JOIN `user` my ON my.uid=:uid
WHERE (( (f.tid=:uid) OR (f.uid=:uid) ) AND (f.status=1))
ORDER BY f.id DESC
Комментарии
Оставить комментарий
Базы данных - MySql (Maria DB)
Термины: Базы данных - MySql (Maria DB)