Hallo Jungs hier sind meine MySQL-Abfrage, die eine Daten bekommen ...Schwierige SQL-Abfragesyntax
$videofetch = $conn->prepare("select * from user_followers as uf join videos as v on uf.followed_id = v.publisher_id where uf.follower_id = ? order by video_id desc limit 5");
$videofetch->execute(array(@$_SESSION ["userid"]));
$vid = $videofetch->fetchALL(PDO::FETCH_ASSOC);
Dieser Code perfekt funktioniert, aber wenn ich ich nicht schreiben kann ich versucht, mehr Daten mit AJAX zu erhalten die richtige SQL-Abfragesyntax.
<?php
session_start();
if(isset($_POST["id"]) && !empty($_POST["id"])) {
include('connectdb.php');
$lastID = $_POST['id'];
$videofetch = $conn->prepare("select * from user_followers as uf join videos as v on uf.followed_id = v.publisher_id where uf.follower_id = ? order by video_id desc limit 5");
$videofetch->execute(array($_SESSION["userid"]));
$vid = $videofetch->fetchALL(PDO::FETCH_ASSOC);
...
Ich möchte WHERE video_id < ".$lastID."
hinzuzufügen .. Ich habe versucht paar Kombinationen aber immer Syntaxfehler angezeigt werden.
Hinweise:
1- Ich erhalte Daten von AJAX zu $lastID
;
2- $_SESSION ["userid"]
aktiv ist, sorgen Sie sich nicht über dieses
3-SQL-Fehler ist:
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as v on uf.followed_id = v.publisher_id where uf.follower_id = '1' order by vid' at line 1 in C:\wamp64\www\hola.com\functions\getdatafoll.php on line 9
'Videos als v' =>' Videos v' - Sie verwenden 'AS' für Aliasing-Spalten, nicht Tabellen. – Qirel
Nehmen Sie die AS aus Ihrer Tabelle Alias für Videos –
erste Abfrage funktioniert godd nur ich möchte hinzufügen 'WHERE video_id <". $ LastID. "' Zur zweiten Abfrage –