php - SQL for related videos -
what need query related videos in page shows video youtube. however, should choose related videos database. table structure is:
id, privatepublic, singer, title, datetime, gender, difficulty, ytid, lang
title : (title of song), ytid : yotube id of video, lang : language of song, difficulty : ranged 0 10.
requirements:
- privatepublic should 1
- gender should same current video
- at top same singer videos should displayed sorted datetime
- after "singer" section @ 3, should display songs same gender , closest difficulty .
- max number of videos related should 5.
i beginner sql. thank answers.
for used integrated php:
$qry_select="select songs.* songs (((songs.gender)='".$_session['gender']."')) , (((songs.ytid)<>'".$_session['ytid']."')) , (((songs.privatepubblic)=1)) , (((songs.lang)='".$_session['songlang']."')) order rand() limit 0,5;";
after 2-3 days of trial finded code: (songinfo comes get)
(select songs.* songs author = '".$songinfo['author']."' , lang='".$songinfo['lang']."' , title<>'".$songinfo['title']."' order datetime desc limit 2) union (select * `songs` gender='".$songinfo['gender']."' , lang='".$songinfo['lang']."' , title<>'".$songinfo['title']."' order abs(difficulty-4) limit 5)limit 5
Comments
Post a Comment