fazzfarrell Posted January 30, 2007 Share Posted January 30, 2007 I have a database where the numbering starts at 48 and goes on 49, 50 etc.When I view my data 49-99 display in the correct order, but i think it is seeing '100' as '1' as this appears as the first entry?Never had this before and cant see why it is happening? Link to comment https://forums.phpfreaks.com/topic/36319-numbering-problem/ Share on other sites More sharing options...
trq Posted January 30, 2007 Share Posted January 30, 2007 What field type is the field in question? Link to comment https://forums.phpfreaks.com/topic/36319-numbering-problem/#findComment-172684 Share on other sites More sharing options...
fazzfarrell Posted January 30, 2007 Author Share Posted January 30, 2007 its an auto increment int(11) Link to comment https://forums.phpfreaks.com/topic/36319-numbering-problem/#findComment-172688 Share on other sites More sharing options...
trq Posted January 30, 2007 Share Posted January 30, 2007 Then there should'nt be a problem.However, PRIMARY KEYS are not designed to be relied upon for sorting. What is it you are doing excactly? Link to comment https://forums.phpfreaks.com/topic/36319-numbering-problem/#findComment-172689 Share on other sites More sharing options...
fazzfarrell Posted January 30, 2007 Author Share Posted January 30, 2007 I have this:SELECT ID, DATE, USERNAME, TITLE, MESSAGE FROM Message UNION ALL SELECT ReplyID, DATE, USERNAME, TITLE, MESSAGEFROM MessageRORDER BY ID DESCAll works fine untill the 100th entry was made.thanks Link to comment https://forums.phpfreaks.com/topic/36319-numbering-problem/#findComment-172691 Share on other sites More sharing options...
trq Posted January 30, 2007 Share Posted January 30, 2007 Why are you ordering by ID and not DATE? Link to comment https://forums.phpfreaks.com/topic/36319-numbering-problem/#findComment-172693 Share on other sites More sharing options...
fazzfarrell Posted January 30, 2007 Author Share Posted January 30, 2007 Tried by date, but as the page groups replys on the forum and each reply groups itself under the question it answered. At the moment it flows fine, but if I do it by date the replys go above the questions Link to comment https://forums.phpfreaks.com/topic/36319-numbering-problem/#findComment-172695 Share on other sites More sharing options...
trq Posted January 30, 2007 Share Posted January 30, 2007 Sounds like you have some database design issues more than anything.Anyway, odering by an autoincrement field is a bad idea. There is no guarantee they will stay in order, that is not there intended purpose (Im sure Ive said it before). Link to comment https://forums.phpfreaks.com/topic/36319-numbering-problem/#findComment-172698 Share on other sites More sharing options...
fazzfarrell Posted January 30, 2007 Author Share Posted January 30, 2007 Ok if I dont use that auto increment field how do I go about numbering another field when someone makes an entry? Link to comment https://forums.phpfreaks.com/topic/36319-numbering-problem/#findComment-172702 Share on other sites More sharing options...
craygo Posted January 30, 2007 Share Posted January 30, 2007 try[code]SELECT ID, DATE, USERNAME, TITLE, MESSAGEFROM MessageUNION ALLSELECT ReplyID, DATE, USERNAME, TITLE, MESSAGEFROM MessageRORDER BY Message.DATE DESC, MessageR.Date DESC[/code]One other thing, Using UNION is probably not your best bet here. If someone answers a message that is really old it will not show correctly. I am guessing that you want to have the messages show, and under each message show replies. If that is the case you should link the 2 tables with a common field.Message table can stay the same but you should add a field in MessageR called MessageID. This should contain the ID from the message table that way when you query it will link everything together.[code]SELECT Message.DATE AS m_date, Message.USERNAME AS m_user, Message.TITLE AS m_title, Message.MESSAGE AS m_message, MessageR.DATE AS r_date, MessageR.TITLE AS r_title, MessageR.MESSAGE AS r_message FROM MessageLEFT JOIN MessageR ON Message.ID = MessageR.MessageIDORDER BY Message.DATE DESC, MessageR.Date DESC[/code]Now the tables are linked.Ray Link to comment https://forums.phpfreaks.com/topic/36319-numbering-problem/#findComment-172723 Share on other sites More sharing options...
fazzfarrell Posted January 30, 2007 Author Share Posted January 30, 2007 Thanks for that,But still does not work? Link to comment https://forums.phpfreaks.com/topic/36319-numbering-problem/#findComment-172742 Share on other sites More sharing options...
fazzfarrell Posted January 30, 2007 Author Share Posted January 30, 2007 I have set it up like this as i already had a field that held the ID number from the Message table.[code]SELECT Message.DATE AS m_date, Message.USERNAME AS m_user, Message.TITLE AS m_title, Message.MESSAGE AS m_message, MessageR.DATE AS r_date, MessageR.TITLE AS r_title, MessageR.MESSAGE AS r_message FROM MessageLEFT JOIN MessageR ON Message.ID = MessageR.MessageIDORDER BY Message.DATE DESC, MessageR.Date DESC[/code]Problem is now that it is not showing all the mesages from both tables, it just repeats any entry with a reply twice? Link to comment https://forums.phpfreaks.com/topic/36319-numbering-problem/#findComment-172828 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.