Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.