Jump to content

Join


timmah1
Go to solution Solved by Barand,

Recommended Posts

Can somebody help me as to why I'm not getting any results?

$today = date("Y-m-d");

$week = date("Y-m-d", strtotime("+7 day"));

 

$sql = "SELECT * FROM schedule as t1

inner join 

teams as t2

on t1.schedule_home=t2.team_id

inner join

team as t3

on t1.schedule_away=t3.teams_id 

inner join

schedule as t4

on t4.schedule.date > '$today' WHERE t1.schedule.date < '$week' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo 'Results';
} else {
echo 'No Upcoming Games';
}

I'm trying to get all games that are greater than today's date, but  less than 7 days from now

Link to comment
Share on other sites

Yes, it is teams_id and team_id, those are correct.

 

This always returns nothing, no games found, but there are games, 8 of them, on September 2nd.

 

It works if i don't try to grab dates in between 2 dates, so that's why I'm not sure what is wrong.

Link to comment
Share on other sites

Im getting the same results doing this

 

$sql = "SELECT * FROM schedule as t1
inner join 
teams as t2
on t1.schedule_home=t2.team_id
inner join
team as t3
on t1.schedule_away=t3.teams_id WHERE t4.schedule.date > '$today' OR t1.schedule.date < '$week' ";
Link to comment
Share on other sites

Sorry, I noticed that after I posted it

 

I have this

 

$sql = "SELECT * FROM schedule as t1
inner join 
teams as t2
on t1.schedule_home=t2.team_id
inner join
team as t3
on t1.schedule_away=t3.teams_id WHERE t1.schedule.date > '$today' OR t1.schedule.date < '$week' ";
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.