You get a bonus - 1 coin for daily activity. Now you have 1 coin

Friends, friends of friends, and similar recommended products

Practice




friends and friends of friends, and similar recommended products


$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

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Databases - MySql (Maria DB)"

Terms: Databases - MySql (Maria DB)