• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Help with changing this sql code

chrisj

Coder
I didn’t write this web script code, but I’m trying to modify it.
I am attempting to have this:

Code:
$get_videos = $db->rawQuery("SELECT DISTINCT(v.id), v.* FROM u_paid_videos AS upv LEFT JOIN " . T_VIDEOS . " AS v ON (upv.id_video = v.id) WHERE upv.id_user = {$user->id} AND upv.session_key = '{$_SESSION['session_key']}' ORDER BY upv.id DESC");

have it work from another table: ‘videos_transactions’ (instead of u_paid_videos).
I’m sure overall it can be improved, but first I’d like to get this working.

I’ve tried this modified line without success:

Code:
$get_videos = $db->rawQuery("SELECT DISTINCT(v.id), v.* FROM videos_transactions AS vt LEFT JOIN " . T_VIDEOS . " AS v ON (vt.video_id = v.id) WHERE vt.user_id = {$user->id} AND vt.session_key = '{$_SESSION['session_key']}' ORDER BY vt.id DESC");

Being there is a ‘videos’ table in the db, and this is about get_videos, would I be correct to assume that v.* is ‘videos’ table? I think T_VIDEOS might mean ‘videos’ table. And I can tell you that ‘videos_transations’ table has video_id field, user_id field and session_key field in it, with the same structure as the same fields in ‘u_paid_videos’.

Can you suggest possibly why the modified line isn’t working?

I look forward to any guidance.
 

Top