drranch Posted November 18, 2007 Share Posted November 18, 2007 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 Quote Link to comment Share on other sites More sharing options...
AdRock Posted November 18, 2007 Share Posted November 18, 2007 Can you show your table structure? I have been using inner joins Quote Link to comment Share on other sites More sharing options...
drranch Posted November 18, 2007 Author Share Posted November 18, 2007 show table: username show_title follow_up_date appointment table username title follow_up_date Quote Link to comment Share on other sites More sharing options...
drranch Posted November 20, 2007 Author Share Posted November 20, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.