brob Posted January 31, 2007 Share Posted January 31, 2007 Hi I want to be able to merge two sets of data if they both have the same id.Here is the query that I am running.[code]$result=mysql_query("select start_time, end_time, room_id, name, description, mobile_no from mrbs_entry, mrbs_tel where mrbs_entry.room_id = mrbs_tel.contact_id and start_time >= '$today_start' and end_time < '$today_end'"); while ($i = mysql_fetch_row($result))[/code]it then pulls out the information but if there are two entries with different inforamtion but the same id it lists them seperatly and I want to be able to list them in one.Can anyone help with this?Thanks Link to comment https://forums.phpfreaks.com/topic/36479-merging-data-if-id-is-the-same/ Share on other sites More sharing options...
paul2463 Posted January 31, 2007 Share Posted January 31, 2007 which id value are you talking about haveing 2 with different information???id values are generally unique, thats why they are called id.... Link to comment https://forums.phpfreaks.com/topic/36479-merging-data-if-id-is-the-same/#findComment-173627 Share on other sites More sharing options...
brob Posted January 31, 2007 Author Share Posted January 31, 2007 Hi I'm using a while loop to pull out the information listed above (which is a calendar)The ID that is being pulled out is the room_id and this can have more than one entry. So if there is more than one I want to be able to merge them into one.I sthis possible? Link to comment https://forums.phpfreaks.com/topic/36479-merging-data-if-id-is-the-same/#findComment-173629 Share on other sites More sharing options...
paul2463 Posted January 31, 2007 Share Posted January 31, 2007 you can call <a href="http://www.webdevelopersnotes.com/tutorials/sql/online_mysql_guide_the_distinct_keyword.php3">DISTINCT </a>room_id in the query which means that only ever 1 of the room ids will be called Link to comment https://forums.phpfreaks.com/topic/36479-merging-data-if-id-is-the-same/#findComment-173638 Share on other sites More sharing options...
brob Posted January 31, 2007 Author Share Posted January 31, 2007 Hi thanks for the reply. I don't want to call only one I need to be able to call all of the entries for this room_id and then add them into one statement. Link to comment https://forums.phpfreaks.com/topic/36479-merging-data-if-id-is-the-same/#findComment-173640 Share on other sites More sharing options...
paul2463 Posted January 31, 2007 Share Posted January 31, 2007 i am confused as to what you want to do now Link to comment https://forums.phpfreaks.com/topic/36479-merging-data-if-id-is-the-same/#findComment-173644 Share on other sites More sharing options...
brob Posted January 31, 2007 Author Share Posted January 31, 2007 Sorry for the confusion.I am pulling information from a calendar and each day the calendar shows the rooms booked out for a day. The room is used more than once a day.This means that in the database has multiple room_id's for the specific time period. I need to be able to pull all of the entries for that room_id and time period into one statment.Does this make more sense? Link to comment https://forums.phpfreaks.com/topic/36479-merging-data-if-id-is-the-same/#findComment-173648 Share on other sites More sharing options...
brob Posted January 31, 2007 Author Share Posted January 31, 2007 anyone know how to do this pls? Link to comment https://forums.phpfreaks.com/topic/36479-merging-data-if-id-is-the-same/#findComment-173718 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.