Maison > Questions et réponses > le corps du texte
C'est le php
code que j'utilise
$Last_Video = $db->fetch_all(' SELECT VID, thumb FROM video WHERE VID IN ( SELECT VID FROM video WHERE title LIKE "%'.$Channel['name'].'%" ORDER BY viewtime DESC LIMIT 5) ORDER BY RAND() LIMIT 1 ');
C'est l'erreur qu'il m'a donné
Message: Error during SQL execution: SELECT VID, thumb FROM video WHERE VID IN ( SELECT VID FROM video WHERE title LIKE "%funny%" ORDER BY viewtime DESC LIMIT 5) ORDER BY RAND() LIMIT 1<br /> MySQL Error: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'<br /> MySQL Errno: 1235
P粉7029469212023-10-17 18:53:50
Vous pouvez utiliser les méthodes suivantes pour contourner cette erreur.
$Last_Video = $db->fetch_all(' SELECT VID, thumb FROM video WHERE VID IN (select * from ( SELECT VID FROM video WHERE title LIKE "%'.$Channel['name'].'%" ORDER BY viewtime DESC LIMIT 5) temp_tab) ORDER BY RAND() LIMIT 1 ');
P粉2835590332023-10-17 10:50:25
Vous pouvez utiliser JOIN au lieu de IN
SELECT v.VID, v.thumb FROM video AS v INNER JOIN (SELECT VID FROM video WHERE title LIKE "%'.$Channel['name'].'%" ORDER BY viewtime DESC LIMIT 5) as v2 ON v.VID = v2.VID ORDER BY RAND() LIMIT 1