Jump to content

[SOLVED] looking for assistance on pulling data from multiple tables


drranch

Recommended Posts

I would like to pull appointment dates from 4 different tables and display the appointments that are with in a certain time from. 

 

"SELECT * FROM show WHERE follow_up_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND DATE_ADD(CURDATE(), INTERVAL 7 DAY) ORDER BY follow_up_date DESC "

 

When I do a join i get the message...

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/testing/html/testscript.php on line 9

 

Here is the join script...

SELECT * FROM show, appointment WHERE show.username = appointment.username AND follow_up_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND DATE_ADD(CURDATE(), INTERVAL 7 DAY) ORDER BY follow_up_date DESC

 

 

 

 

Link to comment
Share on other sites

OK...........

 

I figured it out.  Its very complicated to esplain ;) buuuuuuuuuut... since my tables had the same names I had to change the name of the fields in the query by using the AS statment. 

 

example...

 

select show_table.username, show_table.follow_up_date AS sttable, appointment_table.username, appointment.follow_up_date AS atfollow_up_date from show_table, appointment_table WHERE show_table.username = appointment_table.username...

 

I was also able to narrow down the query by using the BETWEEN statement to gather only a certain range of dates and using the DATE_ADD and DATE_SUB  Pretty cool stuff...........Having fun learning all this stufffffffffff

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.