Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 329463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:35:27+00:00 2026-05-12T09:35:27+00:00

I’m currently working on an Equipment Reservation System for my school. Here’s basically what

  • 0

I’m currently working on an Equipment Reservation System for my school.

Here’s basically what my tables look like:

tblEquipment:

     id    name          description
      1   Camera        Takes pictures
      2   Projector     Projects images
      3   Stereo        Plays music

tblEvents:

      id       equipmentID        start             end
       1          2,3           1251312300     1251315900    //Should I use comma delimited entries for equipmentID?   
       2           1            1251312300     1251315900    

Regarding my project, I have a couple of questions:

1) If multiple pieces of equipment are being reserved, (which will happen more times than not) should the “equipmentIDs” be comma delimited in the equipmentID field?

2) Currently, when a user makes a reservation, they first select their “requested times”, then are presented with available items at that time. Here’s what I am using for that query:

$start = //user's requested time
$start = //user's requested time

SELECT equipmentID FROM tblEvents
 WHERE ($start >= start && $start <= end) 
 OR ($end >= start && $end <= end)
 OR ($start <= start && $end >= end

 while($row = mysql_fetch_array($data)) {

  echo $row['equipmentID'];  //Would echo something like: 
  echo "<br>";               //    2,3
                            //    1

 }

My question is this:

How can I take the ‘results’ of the above query to then re-query the ‘tblequipment’ table, but exclude the items that were in the ‘results’ above (because they would not be available). Keeping in mind, that my query above may return multiple rows.

Any help on this would be great, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:35:27+00:00Added an answer on May 12, 2026 at 9:35 am

    Regarding #1: No! No, no, no, no, no! If you have multiple pieces of equipment being reserved, then you should have multiple rows in the reservations table (what looks like tblEvents here). To avoid duplicating the other fields in tblEvents, you’d typically create a third table, perhaps tblEventEquipment that simply lists what equipment belongs with what event.

    If you need a comma-separated list for the purposes of output (which doesn’t seem likely), you can always generate one with GROUP_CONCAT(), but inside the table you want one row per reserved piece of equipment. Otherwise, SQL cannot effectively (or efficiently) determine what equipment is reserved at a particular time.

    Regarding #2, you want a query like:

    SELECT * 
    FROM tblEquipment
    WHERE NOT EXISTS (
      SELECT 1 
      FROM tblEvents 
      WHERE tblEvents.equipmentID = tblEquipment.equipmentID
        AND $end >= start AND $start <= end
    )
    

    This selects equipment for which there isn’t a reservation. Note that I simplified your logic for determining whether the equipment is reserved or not by doing just two comparisons.

    Finally, an unrelated note: I recommend strongly against storing timestamps as integers in the database table. Use MySQL’s built-in DATETIME type. If you need to convert to/from a timestamp, you can use the UNIX_TIMESTAMP() and FROM_UNIXTIME() functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.