GreenSmurf Posted July 14, 2008 Share Posted July 14, 2008 SELECT * , IF ( month_lookup.bmonth_num < MONTH( CURDATE( ) ) OR month_lookup.bmonth_num = MONTH( CURDATE( ) ) AND table.bday < DAYOFMONTH( CURDATE( ) ) , CONCAT( table.bmonth, ' ', YEAR( CURDATE( ) ) +1 ) , table.bmonth ) display_month, IF ( month_lookup.bmonth_num < MONTH( CURDATE( ) ) OR month_lookup.bmonth_num = MONTH( CURDATE( ) ) AND table.bday < DAYOFMONTH( CURDATE( ) ) , month_lookup.bmonth_num+12, month_lookup.bmonth_num )*32+bday prio FROM $month_lookup, addressbook WHERE table.bmonth = month_lookup.bmonth ORDER BY prio ASC For some odd reason this code finds each instance three times. Attatched is an image to give you an idea of what I am talking about. Also, I ahve checked the query in HeidiSQL and it is the query not my php loop that is creating the problem. I even checked the actual table and each entry is in there only once. The 'id' number associated with each is a dead give away that each row is being displaed multiple times. Any suggestions would be great, thanks. -Brandon Quote Link to comment Share on other sites More sharing options...
fenway Posted July 15, 2008 Share Posted July 15, 2008 This: FROM $month_lookup, addressbook WHERE table.bmonth = month_lookup.bmonth Is strange -- and is php. Quote Link to comment Share on other sites More sharing options...
GreenSmurf Posted July 15, 2008 Author Share Posted July 15, 2008 This: FROM $month_lookup, addressbook WHERE table.bmonth = month_lookup.bmonth Is strange -- and is php. Yeah sorry, I was trying to make it look like it normally would in mySQL form. I forgot to take the '$' out and rename the table to addressbook. I will post the real mySQL code and its results soon. Quote Link to comment Share on other sites More sharing options...
GreenSmurf Posted July 16, 2008 Author Share Posted July 16, 2008 SELECT * , IF ( month_lookup.bmonth_num < MONTH( CURDATE( ) ) OR month_lookup.bmonth_num = MONTH( CURDATE( ) ) AND addressbook.bday < DAYOFMONTH( CURDATE( ) ) , CONCAT( addressbook.bmonth, ' ', YEAR( CURDATE( ) ) +1 ) , addressbook.bmonth ) display_month, IF ( month_lookup.bmonth_num < MONTH( CURDATE( ) ) OR month_lookup.bmonth_num = MONTH( CURDATE( ) ) AND addressbook.bday < DAYOFMONTH( CURDATE( ) ) , month_lookup.bmonth_num+12, month_lookup.bmonth_num )*32+bday prio FROM month_lookup, addressbook WHERE 1=1 AND addressbook.bmonth = month_lookup.bmonth ORDER BY prio ASC Here is the actualy mySQL query. Any help would be apperciated. Thank you. -Brandon Quote Link to comment Share on other sites More sharing options...
fenway Posted July 16, 2008 Share Posted July 16, 2008 Then it sounds like bmonth isn't unique enough. Quote Link to comment Share on other sites More sharing options...
GreenSmurf Posted July 16, 2008 Author Share Posted July 16, 2008 I do not follow you- how is it not unique enough? -Brandon Quote Link to comment Share on other sites More sharing options...
GreenSmurf Posted July 17, 2008 Author Share Posted July 17, 2008 if ($prevID != $id) { $prevID = $id; ... } In the meanwhile I used this if statement to control the excessive listsing that the query returns. I would much rather that the mySQL query NOT have this problem but I have been over it time and time again and I can't see why it returns results three times. Thank you to fenway for trying to help. -Brandon Quote Link to comment Share on other sites More sharing options...
fenway Posted July 17, 2008 Share Posted July 17, 2008 I do not follow you- how is it not unique enough? -Brandon I mean that one bmonth value from one table matches more than one record in the other table. Quote Link to comment Share on other sites More sharing options...
GreenSmurf Posted July 24, 2008 Author Share Posted July 24, 2008 I do not follow you- how is it not unique enough? -Brandon I mean that one bmonth value from one table matches more than one record in the other table. I understand now. You are absolutely right. I had to go and remove multiple entries from the db to fix the problem. All months were listed three times thus returning three results. Thank you. -Brandon 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.