Jump to content

Join


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
https://forums.phpfreaks.com/topic/302023-join/
Share on other sites

 

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

Probably because of query errors.

 

Check what $conn->error contains.

 

Are you sure about the last join and the where condition?

Edited by Barand
Link to comment
https://forums.phpfreaks.com/topic/302023-join/#findComment-1536743
Share on other sites

on t4.schedule.date > '$today' WHERE t1.schedule.date < '$week' ";

              ^                                 ^

              |                                 | 

Link to comment
https://forums.phpfreaks.com/topic/302023-join/#findComment-1536747
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
https://forums.phpfreaks.com/topic/302023-join/#findComment-1536748
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.