Hi
i have the following SQL tables:
My MySQL query is this:
this works fine if the users wants to book something for only one day, but if i have multiple days for one booking (such as book_id 36, which has the book day ids: 64 and 63) it gives me the same booking (from prefix_bookings ) twice, example:
i have also tried to just select it normally 'Select * FROM prefix_bookings as bookings, prefix_booking_ days as bdays WHERE...' but that didn't work either.
Can anyone please help me to only get one record per book id? i need only one 'bday_id' but not 2 'book_id'.
Thanks
i have the following SQL tables:
Code:
prefix_bookings: +---------+------------+-----------------+-------------+---------------+ | book_id | book_place | book_customerid | book_adults | book_children | +---------+------------+-----------------+-------------+---------------+ | 3 | 1 | 1 | 2 | 2 | | 42 | 1 | 1 | 2 | 2 | | 41 | 1 | 1 | 1 | 1 | | 40 | 1 | 2 | 1 | 1 | | 39 | 1 | 2 | 1 | 1 | | 38 | 1 | 2 | 1 | 1 | | 37 | 1 | 2 | 1 | 1 | | 36 | 1 | 1 | 2 | 2 | | 35 | 1 | 1 | 2 | 2 | +---------+------------+-----------------+-------------+---------------+ prefix_book_days: +--------+--------------+------------+------------+ |bday_id | bday_book_id | bday_date | bday_place | +--------+--------------+------------+------------+ | 1 | 1 | 1222945199 | 1 | | 2 | 1 | 1223031599 | 1 | | 3 | 2 | 1221908399 | 1 | | 4 | 2 | 1221994799 | 1 | | 5 | 3 | 1222340399 | 1 | | 6 | 4 | 1221735599 | 1 | | 64 | 36 | 1222858799 | 1 | | 63 | 36 | 1222426799 | 1 | | 65 | 37 | 1221562799 | 1 | | 66 | 39 | 1221476399 | 1 | | 67 | 40 | 1222772399 | 1 | | 68 | 41 | 1222167599 | 1 | | 69 | 42 | 1221649199 | 1 | +--------+--------------+------------+------------+
Code:
SELECT * FROM prefix_bookings as bookings JOIN prefix_booking_days as day ON bookings.book_id=day.bday_book_id
Code:
+---------+---------+ | book_id | bday_id | +---------+---------+ | 3 | 5 | | 36 | 64 | | 36 | 63 | +---------+---------+
Can anyone please help me to only get one record per book id? i need only one 'bday_id' but not 2 'book_id'.
Thanks
Comment