Jump to content

Recommended Posts

Hi,

 

I am querying events for "today". So I have this code:

$query3 ="SELECT * FROM `mb_foursquare`.`eventsbydate` WHERE `mb_foursquare`.`eventsbydate`.`datetime1` BETWEEN DATE_ADD(CURDATE(), INTERVAL -1 DAY) AND DATE_ADD(CURDATE(), INTERVAL 2 DAY)";

 

It works ok (if there is a better way to do this, feel free to let me know). But then I also need to pull data from a different table. So I added the other query but somehow it is triggering an error. Not sure what could be wrong, could you please help me?

 

Here is the code that's triggering an error:

$query3 ="SELECT * FROM `mb_foursquare`.`eventsbydate` WHERE `mb_foursquare`.`eventsbydate`.`datetime1` BETWEEN DATE_ADD(CURDATE(), INTERVAL -1 DAY) AND DATE_ADD(CURDATE(), INTERVAL 2 DAY), `mb_foursquare`.`venues` WHERE eventsbydate.v_id = venues.v_id";

 

Thank you!

Thank you. That's only because i am querying 2 tables.

 

I have this on one side:

`mb_foursquare`.`eventsbydate` WHERE `mb_foursquare`.`eventsbydate`.`datetime1` BETWEEN DATE_ADD(CURDATE(), INTERVAL -1 DAY) AND DATE_ADD(CURDATE(), INTERVAL 2 DAY)

 

And this on the other side:

`mb_foursquare`.`venues` WHERE eventsbydate.v_id = venues.v_id

 

 

Thank you again. Let me be a little more specific about what i want to do: I am selecting from my event table (eventsbydate) all the events that are happening today. Then I am also pulling data on all the venues from a different table (venues).

 

I tried this and it is still triggering an error... :(

 

SELECT * FROM `mb_foursquare`.`eventsbydate` 
WHERE `mb_foursquare`.`eventsbydate`.`datetime1` 
BETWEEN DATE_ADD(CURDATE(), INTERVAL -1 DAY) AND DATE_ADD(CURDATE(), INTERVAL 2 DAY) 
LEFT JOIN `mb_foursquare`.`venues` ON eventsbydate.v_id = venues.v_id

 

Any idea what the issue could be?

 

Thank you. Actually, I figured it out!

 

SELECT * FROM `mb_foursquare`.`eventsbydate`, `mb_foursquare`.`venues` WHERE DATE(datetime1) = DATE(CURDATE()) AND eventsbydate.v_id = venues.v_id

 

I had to put the FROM table 1, table 2 at the very beginning. and attach the WHENs with an AND.

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.