我需要的是在显示来自youtube的视频的页面中查询相关视频。但是,它应该从我的数据库中选择相关的视频。我的表结构是:
id,privatepublic,singer,title,datetime,gender,difficulty,ytid,lang
标题:(歌曲的标题), ytid:视频的Yotube ID, 郎:这首歌的语言, 难度:范围从0到10.
要求:
我是SQL的初学者。谢谢你的回答。
现在我用它与PHP集成:
$qry_select="SELECT songs.* FROM songs
WHERE (((songs.gender)='".$_SESSION['gender']."')) AND
(((songs.ytid)<>'".$_SESSION['ytid']."')) AND
(((songs.privatepubblic)=1)) AND (((songs.lang)='".$_SESSION['songlang']."'))
ORDER BY RAND()
limit 0,5;";
答案 0 :(得分:0)
经过2-3天的试用,我找到了代码:( songInfo附带GET)
(SELECT songs.* FROM songs WHERE author = '".$songInfo['author']."'
AND lang='".$songInfo['lang']."'
AND Title<>'".$songInfo['Title']."'
ORDER BY datetime DESC LIMIT 2)
UNION
(SELECT * FROM `songs` WHERE gender='".$songInfo['gender']."'
AND lang='".$songInfo['lang']."'
AND Title<>'".$songInfo['Title']."'
ORDER BY ABS(difficulty-4) LIMIT 5)limit 5