0

Ok, I have two tables: points and videos. I only want a video to show if the logged in user hasn't already been awarded points for watching that particular video.

The points db structure: id, special, user and points.

Special is the unique id of the video.

The videos db structure: id, title, points, src, photo, token, special.

There are multiple pages on this site. Token tells the video which page that video is ssigned to. Special is a special id for only that video and correlates to the special in the points db

This is the SQL Query I basicially want to say:

$db->query("SELECT * FROM videos WHERE token='$id' AND num_rows OF user='$user' AND special='$special' == 0 FROM TABLE points"); 

Now I know this is not the proper format to write SQL Queries, but this is what I want in human. How do I translate this request to SQL?

By the way, it's also important that I can fetch the title, points, src and photo from the SQL Query. I'm been trying to do do this, but it's difficult to fetch something from one db while using parameters from a different db.

Machavity
  • 30,841
  • 27
  • 92
  • 100
user6902601
  • 123
  • 2
  • 10

2 Answers2

0

Try using INNER

SELECT column_name(s)
FROM table1
INNER JOIN table2 ON table1.column_name = table2.column_name;enter code here

https://www.w3schools.com/sql/sql_join_inner.asp

GDP
  • 107
  • 6
0

Try this:

SELECT *
FROM `videos` a
JOIN `points` b
ON a.`special` = b.`special`
WHERE a.`token` = '$id'
Sloan Thrasher
  • 4,953
  • 3
  • 22
  • 40