Jump to content

[SOLVED] complex query help


dannyone

Recommended Posts

hello everyone i have a problem, i have got 3 working querys, to show on seperate tables, however i need to either combine these 3 querys to show all the information in one table, or i need to run the querys straight after each other so i can do it.

 

my aim is to show a table of all the times that are available for 3 selected rooms. the 3 querys i have work , seperatly, but i dont know how to join them. can any one help

 

here are my 3 working querys

 

"SELECT Marker_Rooms.Room_ID, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE Marker_ID = '" .$_SESSION['login'] . "' AND Marker_Rooms.Room_ID = Rooms_Free.Room_ID AND Rooms_Free.status = '0'"

 

SELECT Marker_Rooms.Room_ID1, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE Marker_ID = '" .$_SESSION['login'] . "' AND Marker_Rooms.Room_ID1 = Rooms_Free.Room_ID AND Rooms_Free.status = '0'"

 

"SELECT Marker_Rooms.Room_ID2, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE Marker_ID = '" .$_SESSION['login'] . "' AND Marker_Rooms.Room_ID2 = Rooms_Free.Room_ID AND Rooms_Free.status = '0'"

 

 

Here is a query i tried but it just displays all records in the table regardless is they have status 0 or not.

 

"SELECT Marker_Rooms.Room_ID, Marker_Rooms.Room_ID1, Marker_Rooms.Room_ID2, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE (Marker_Rooms.Room_ID = Rooms_Free.Room_ID AND Marker_Rooms.Marker_ID = '" .$_SESSION['login'] . "' AND Rooms_Free.status = '0') OR (Marker_Rooms.Room_ID1 = Rooms_Free.Room_ID AND Marker_Rooms.Marker_ID = '" .$_SESSION['login'] . "' AND Rooms_Free.status = '0') OR (Marker_Rooms.Room_ID2 = Rooms_Free.Room_ID AND Marker_Rooms.Marker_ID = '" .$_SESSION['login'] . "' AND Rooms_Free.status = '0')"

 

any help would be fantastic

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/151629-solved-complex-query-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.