SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    London UK, Tokyo, Japan
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up adding second occurance in array from mysql

    This is my DB

    Code:
    Table: room_des
    +----+------------+-------------------------------+
    | ID | rtype      | Room name                     |
    +----+------------+-------------------------------+
    | 1  | 1          | Standard Room - 1 Double Bed  |
    +----+------------+-------------------------------+
    | 2  | 2          | Standard Room - 2 Double Beds |
    +----+------------+-------------------------------+
    
    Table: room
    +----+------------+--------------+------------+
    | ID | room_type  | Rate         | Ref        |
    +----+------------+--------------+------------+
    |  1 | 1          | 15           | 1163133652 |
    +----+------------+--------------+------------+
    |  2 | 2          | 20           | 1163133652 |
    +----+------------+--------------+------------+
    |  3 | 2          | 20           | 1163133652 |
    +----+------------+--------------+------------+
    i want to know how i can get the info of room_type 2 in one line instead of getting 2 seprate lines...

    i want the ouput to be like this

    PHP Code:
    Reservation Details

    1 x Standard Room 
    1 Double Bed

      Rate 
    for each room: $15


    2 x Standard Room 
    2 Double Beds
     
      Rate 
    for each room: $20 
    do i need some join query or some php to detect that there are 2 room_type 2 enteries where ref=1163133652

    please help, am so lost on this!

  2. #2
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this (untested):
    Code:
    SELECT room_name, COUNT(room_type) AS count
    FROM room
    LEFT OUTER JOIN room_des
        ON rtype=room_type
    GROUP BY room_type


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •