All pastes #28502 Raw Edit

Someone

public text v1 · immutable
#28502 ·published 2005-11-13 00:30 UTC
rendered paste body
SELECT rentals.id, rentals.property_name, rentals.property_state_id, rentals.property_city, rentals.property_address, rentals.property_zip, rentals.property_headline,
      rentals.housing_type_id, rentals.pet_id, rentals.date, rentals.time, amenities.amenity_id
FROM tbl_rental_items AS rentals, tbl_units AS units, tbl_amenities AS amenities
WHERE rentals.id=units.rental_id AND rentals.id=amenities.rental_id AND rentals.status='3' AND (amenity_id = '1' AND amenity_id = '2')
GROUP BY rentals.id


mysql> select * from tbl_amenities;
+-----------+------------+
| rental_id | amenity_id |
+-----------+------------+
|         8 |          1 |
|         8 |          2 |
+-----------+------------+


mysql> mysql> select * from tbl_rental_items limit 10;
+----+---------+-----------------+-------------------+----------------------------------+------------------+---------------+--------------+----------------------+-------------------+--------+---------+---------------+---------+------------+----------+---------------------+--------+
| id | user_id | housing_type_id | property_state_id | property_name                    | property_address | property_city | property_zip | property_description | property_headline | pet_id | deposit | display_phone | prod_id | date       | time     | readable_timestamp  | status |
+----+---------+-----------------+-------------------+----------------------------------+------------------+---------------+--------------+----------------------+-------------------+--------+---------+---------------+---------+------------+----------+---------------------+--------+
|  1 |       1 |               1 |                 5 | Cali test                        | Test             | Beverly Hills | 90210        | Test                 | Test              |      1 | 0       |             1 |       2 | 2005-11-03 | 16:12:13 | 2005-11-04 19:29:56 |      3 |
|  5 |       1 |               2 |                 5 | Rer                              | Rer              | Beverly Hills | 90210        | Fefe                 | Fefe              |      4 | 0       |             1 |       2 | 2005-11-05 | 01:53:04 | 2005-11-05 02:20:33 |      3 |
|  6 |       1 |               1 |                 5 | Image test when listing a rental | Test             | Beverly Hills | 90210        | Test                 | Test              |      3 | 0       |             1 |       2 | 2005-11-05 | 13:49:31 | 2005-11-07 19:59:46 |      3 |
|  7 |       1 |               1 |                 5 | Image test when listing a rental | Test             | Beverly Hills | 90210        | Test                 | Test              |      3 | 0       |             1 |       2 | 2005-11-05 | 13:49:51 | 2005-11-07 19:59:31 |      3 |
|  8 |       1 |               1 |                 5 | Image test when listing a rental | Test             | Beverly Hills | 90210        | Test                 | Test              |      3 | 0       |             1 |       2 | 2005-11-08 | 09:28:25 | 2005-11-08 09:28:25 |      3 |
|  9 |       1 |               1 |                23 | Property 1                       | My Street        | Saint Paul    | 55101        | Test                 | Test              |      3 | 0       |             1 |       2 | 2005-11-12 | 15:16:55 | 2005-11-12 15:16:55 |      1 |
| 10 |       1 |               1 |                23 | Property 1                       | My Street        | Saint Paul    | 55101        | Test                 | Test              |      3 | 0       |             1 |       2 | 2005-11-12 | 15:16:55 | 2005-11-12 15:16:55 |      3 |
| 11 |       1 |               1 |                23 | Property 1                       | My Street        | Saint Paul    | 55101        | Test                 | Test              |      3 | 0       |             1 |       2 | 2005-11-12 | 15:16:55 | 2005-11-12 15:16:55 |      3 |
| 12 |       1 |               1 |                23 | Property 1                       | My Street        | Saint Paul    | 55101        | Test                 | Test              |      3 | 0       |             1 |       2 | 2005-11-12 | 15:16:55 | 2005-11-12 15:16:55 |      3 |
| 13 |       1 |               1 |                23 | Property 1                       | My Street        | Saint Paul    | 55101        | Test                 | Test              |      3 | 0       |             1 |       2 | 2005-11-12 | 15:16:55 | 2005-11-12 15:16:55 |      3 |
+----+---------+-----------------+-------------------+----------------------------------+------------------+---------------+--------------+----------------------+-------------------+--------+---------+---------------+---------+------------+----------+---------------------+--------+


mysql> select * from tbl_units;
+-----------+------------+-----------------+---------------+-----------------+---------------+-----------------+---------------+
| rental_id | bedroom_id | bath_range_from | bath_range_to | size_range_from | size_range_to | rent_range_from | rent_range_to |
+-----------+------------+-----------------+---------------+-----------------+---------------+-----------------+---------------+
|         1 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|         2 |          2 |             1.5 |           1.5 |             434 |           434 |             434 |           434 |
|         1 |          5 |             1.0 |           3.0 |               5 |            54 |             100 |           150 |
|         3 |          2 |             1.0 |           1.0 |             333 |           333 |              33 |            33 |
|         4 |          2 |             1.0 |           1.0 |             333 |           333 |              33 |            33 |
|         5 |          2 |             1.5 |           1.5 |             333 |           333 |             333 |           333 |
|         6 |          1 |             1.0 |           1.0 |              33 |            33 |              22 |            22 |
|         7 |          1 |             1.0 |           1.0 |              33 |            33 |              22 |            22 |
|         8 |          1 |             1.0 |           1.0 |              33 |            33 |              22 |            22 |
|         8 |          2 |             1.0 |           3.5 |               4 |            44 |               4 |            44 |
|         8 |          3 |             1.5 |           2.5 |               5 |            55 |               5 |            55 |
|         8 |          4 |             2.5 |           4.0 |               6 |            66 |               7 |            77 |
|         8 |          5 |             1.0 |           2.0 |               8 |            88 |               8 |            88 |
|         8 |          6 |             2.5 |           3.5 |               9 |            99 |              12 |           122 |
|         9 |          3 |             2.0 |           2.0 |             150 |           150 |             500 |           500 |
|        19 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        18 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        17 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        16 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        15 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        14 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        13 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        13 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        12 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        11 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        11 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        10 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        20 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        21 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        22 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|         2 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        23 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
|        23 |          1 |             1.0 |           1.0 |             767 |           767 |              78 |            78 |
+-----------+------------+-----------------+---------------+-----------------+---------------+-----------------+---------------+