Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





How To Check For Date/time Ranges Within Record (check For Schedule Conflicts)


You want to check scheduling conflicts and you have a record like:

appointments(table):
apptID
beginningDate
endingDate
beginningTime
endingTime

It's easy enough to check if a time is within that record. Say you want to
check if 8:00am to 10:00am is available, you would use this:

SELECT apptID
FROM appointments
WHERE (beginningDate = '2006-01-19' OR endingDate = '2006-01-19')
AND ('08:00:00' BETWEEN beginningTime AND endingTime
OR '10:00:00' BETWEEN beginningTime AND endingTime)

BUT, what if you have an all-day appointment (8:00am to 5:00pm) and there
exists an appointment already scheduled from 10:00am to 11:00am. The above
query would not find it.

Another question is what if the appointment is more than two days. Say, it's
from Monday - Wednesday from 8am to 5pm. The above query would not
successfully catch it if you wanted to schedule an appointment on Tuesday.

(I might be able to generate a date range using PHP, don't know if that's
the best way)




View Complete Forum Thread with Replies

Related Forum Messages:
Check If Record Exists
is there a quick and easy way to check if a record exists?
At teh moment I do a select statement then count the rows retrieved, if its greater than 0 I know a record exists. Anyone know of a simpler way or is this it?

View Replies !
Check If A Record Exists In The Last 30 Records
I want to check if a record exists in the last 30 records that were added.

For example, i have a table wich contains about 34000 records by now.

But i want to check if the songID is in the last 30 records.

Now i select the last 30 records and put them in an array, and let php check if this songID is in the array.

But it must be much easier if mysql this does!

View Replies !
IF STATEMENT To Check If Record Exists
I am trying to create a statement that checks a table to see if an entry exists and if it does run one select statement and if the the check comes back with 0 then run another select statement

This is what I have but it doesn't seem to run ? Am I way off ? I can post the exact detailed code but since I am a new to mySQL syntax I am sure it is something basic.

IF (SELECT COUNT(*) FROM table_Y WHERE field_X = 'string') = 1 THEN
SELECT .........
FROM ...........
WHERE ...........
ELSE
SELECT .........
FROM ...........
WHERE ..........
END IF

View Replies !
Time Overlap Check
Im trying to develop a custom appointments/event application, and have run in to the following problem:

Say if a user wants to add an appointment at 07:45 to 08:45 on a particular day, but in the database there is already an appointment for the same person at 07:15 to 09:00 on the same day.

Before I insert the appointment/event into the table how would I go about checking for this overlap? all times will be in a 24hour format.

My database schema is pretty simple and is as follows: ....

View Replies !
Calculating Unused Time, Per Day Given Date Ranges
I've found a few potential solutions to this, but mostly they use Oracle Analytics syntax or SQL server specific extensions. I'm struggling to come up with something that works in Mysql.

I've got a table of date ranges, let's call it "bookings"

Code:

roomid | startdate | enddate
-------+------------------+-----------------
1 | 2008-02-03 13:00 | 2008-02-03 17:00
1 | 2008-02-03 18:00 | 2008-02-03 19:00

I'm trying to come up with a query that will give me the number of unused minutes for a room for a given day, such as:

Code:

roomid | date | unused
-------+------------+-------
1 | 2008-02-02 | 1440
1 | 2008-02-03 | 1140
1 | 2008-02-04 | 1440......

View Replies !
Date Check Constraint
I'm trying to tack on a check constraint to make sure that when a check-out date is added, to make sure the check-in date is <= the check-out date. A simple inequality throws an error. What would be the correct way to handle this?

Create table maintenance(
mid char(5) primary key not null,
cid char(5) not null references cars(cid),
pid char(5) not null references people(pid),
check_in_date date not null,
check_out_date CHECK (check_in_date<= check_out_date),
milage int not null CHECK(milage>=0),
service_description varchar (255),
UNIQUE(mid)
);

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHECK (check_in_date<= check_out_date), milage int not null CHECK(milage>=0), ' at line 6

View Replies !
Check If The Current Date Is Between Two Dates
I have a table with the folowing fields:
- id (int)
- event_title (text)
- event_description (text)
- event_start (date)
- event_end (date)

I would like to know how can I build a query to select the events available between two dates (event_start and event_end).

For example, if one of the event has "event_start" = 2007-06-01 and "event_end" = 2007-06-05, if I select 2007-06-02 as the current date I would like to see this event.

View Replies !
Check IP Against Last Day
I have a database with the following fields:

--------------------------
| id | ipaddress | time |
--------------------------

On each request I log the users IP, but before I let them enter, I want to check their IP against the database.

If their IP has been used more than 300 times (300 requests) in the last day then I want to BAN that IP. I have another table with which holds banned IP numbers. It has an ipaddress field and a timeOfBan field.

The bit which I'm stuck on is how to check the users IP against all IPs used in the last 24 hours and produce a number of how many times that IP has reqeusted... And if it's more than 300 than I ban them.

View Replies !
CHECK Syntax
I have a table as follows:

CREATE TABLE country
(
codeCHAR(2)NOT NULL,
...
...

CHECK (CHAR_LENGTH(code) == 2)
);

The entry for 'code' MUST be two characters long. Although CHECK is not
yet implemented by mySQL, is the above syntax correct?

Secondly, the entry for 'code' MUST not contain any numbers. What is
the syntax to check for that?

Currently I am doing the checking before inserting the data but would
like to implement it in the database too.

View Replies !
Numeric Check
I am looking for some function that tests if a value is numeric. I could not
find a function for this.

At the moment I am using "WHERE CONV(myfield,10,10)!=0" but I suppose there
must be a better way.

View Replies !
Mysql: Check
Is there any possibility to check existing of autoextend option
for InnoDB ?
I mean by any sql command and not by searching in my.ini file ?

View Replies !
Performing A Check
I have a table called customer with a field called dateAtAddress. I want to perfrom a check so that when a new record is created the dateAtAddress must be in the past. I have tried the following code when creating the table

dateAtAddress date,
CHECK
dateAtAddress <= DATE_SUB(CURRENT_DATE, INTERVAL 0 DAY);

But it still seems to be letting datesin the future be entered in as valid data in the field.

View Replies !
Check If Linked
I am trying to return all columns from table1 plus another column with values of true/false (or 1/0, etc) whether it is linked to table2.

For instance, the following table1 and table1x2: ....

View Replies !
Should I Check For ID Before Inserting?
On an app I'm developing, I'm integrating Facebook Connect so people can use that instead of creating an account. I store the users facebook id as a primary key in my database.

When the user logs in, I save their information in case they use other options of my site.

Should I check and see if they are already inserted into the database? The id is unique to the facebook user, so it wont be a duplicate, but I dont know if I should just leave it as is and save one less query on the site.

View Replies !
Syntax Check
Code:

SELECT (((b.close - a.close) / a.close) * 100) FROM `AAH` a, `AAH` b WHERE b.date = '2007-01-03' AND a.date = '2007-01-02'



and said error:

Quote: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'b.close - a.close) / a.close) * 100) FROM `AAH` a, `AAH` b WHERE b.date = '2007-' at line 1
it is supposed to retrieve and calculate the percent change for the closing prices of a symbol on a particular stock market. Not sure what the exact error is.

View Replies !
How To Check Performance?
I have a web application which uses MySQL and I wanted to check out the performance of the database.

I have been trying to use JMeter to test the performance of it but I was wondering if there is anything MySQL specific which can give me statistics on performance etc.

View Replies !
Duplicate Check
I have a table with two columns, T1(id,info). I'd like to add some data from another table which also has two tables T2(id,info).

I have to add data from T2 into T1, but i have to check if the data already exists. Until now i did like this : select info from T1 where info in (select info from T2) but it fails if i have more that 5.000 records. Is there another way to do this ?

View Replies !
Check Constraint
does mySQL provide Check Constraint?

I try this :
alter table city add check(id>0);

It runs without error but when i tried to insert a city name with id = 0 the query runs ok. the check constraint fail to work.

oh ya, what is the syntax to see all the check constraint on a table?

View Replies !
CHECK Command
Could I use the check command to see if a certain identifier will never exceed a default value when data is put into the table.

capacity INTEGER NOT NULL DEFAULT 10,
CHECK(capacity<=10)

View Replies !
SQL To Check For A File?
I have a field in my DB that was pre-populated with a filename for each record. This filename is a picture that then shows up on the website. Problem is not all the pictuers are up yet so they wonderful red X shows instead for ones with no pictures.

We do have it setup so that if there is no picture file specified, it just shows a default "No Image" wording.

So, since all the records already have a filename in them, is there any way with SQL to have it go through the records, check what's in the image field, then see if that file exists or not? THen if it does, great, if it doesn't it would delete the value from the field?

View Replies !
Check For Existing Row ?
How do I determine if a row already exists ?

// see if a row has id=100

$id=100;
$query="SELECT * FROM mytable WHERE id=$id";
$result=mysql_query($query);

...what do I check now ?

View Replies !
Check 366 Day Expiration
Needing to filter on a datetime col Mplan.Start having runtimes of 366 days:

roughly:
SELECT *
FROM Plan
WHERE (CURRENT_DATE () <= Plan.Start + 366 days)

should dates be formatted 1st?

...WHERE DATE_FORMAT(Plan.Start ,'%Y%m%d') >= DATE_FORMAT(CURRENT_DATE(),'%Y%m%d' + ?)

problem with the following is that all future dates are included, as mysql manual states (which can't be included in this application):

...WHERE CURDATE() <=DATE_ADD(Start,INTERVAL 366 DAY)

View Replies !
Check Query Please
This is giving me an mysql error. Why?

DELETE FROM subscribers,list_subscribers WHERE subscribers.id = list_subscribers.ls_sub_id AND list_subscribers.ls_list_id = 1

View Replies !
Check If A Field Is In A Given Set
How do you check if a field is in a given set? I thought it was like this:

mysql_query("UPDATE Topics SET locked='yes' WHERE account='$account' AND topicid IN [".implode(",",$_POST['locked'])."]");

View Replies !
Check Which Server Running
i'd like to know how control which server is actually running between mysqld and mysqld-max.

View Replies !
Duplicate Records Check
Could any one advise what SQL statement I would need to use, to check a
table for any duplicate records e.g that contain the same data within a
field. Note that I haven't got the field as a unqiue field.

View Replies !
Check For Duplicate Databases
I have a program that I am writing in PHP/MySQL. I have made some upgrades
to the database and like an idiot, forgot to write down the changes or to
make the changes in several other databases for the other clients that are
using the program also. What I am trying to do is to have a program,
(preferably in PHP) that will look at the structure of the main database
that I changed, then it will check the other databases to make sure that
the structure is identical and if not, it will change them to make them
identical. Is there a program already out there that would do this?

View Replies !
CHECK CONSTRAINT On A Column
I am not familiar with MySQL, but we are currently looking at it. Currently our software product supports Oracle, DB2, and we want to see what it takes to also include MySQL.

One stumbling block we have come across is that it seems that the CREATE TABLE command does not support the CHECK CONSTRAINT on a column. I know there is such a thing as the ENUM column in MySQL, but what if we want to set the constraint between two values.

Example:

CREATE TABLE TMPTABLE
COLONE CHAR(10),
COLTWO INT CHECK (COLTWO BETWEEN 1 AND 200)....

Is there such a thing in MySQL.

View Replies !
Check If Field Already Exist
How can I check if a field already exist in a table? If it doesn't exist I want
to add it with ALTER TABLE ADD...

View Replies !
How To Check If A Table Is Empty?
I want to check if a table is empty or not?

In my table (i.e test) have no records and id is a primary key as well as auto increment column.

i have using to find this "select count(id) from test"

It gives 1 .

ALso using others query but only get answer 1

View Replies !
Check If Table Is Exist Or Not
May this question exist....But i confused...I want to check whether the table is exist or not ....

Like i run a project , on that project i create a mysql tables while run time.... on that i want to chech a table is exist or not...


if employee table is exist ....

exit;

else

create table employee

View Replies !
Bitwise Check Or Second Table?
IE:
Brand 1 = 1
Brand 2 = 2
Brand 3 = 4
Brand 4 = 8
Brand 1 + 4 = 9
[...]

Then I would do... "WHERE brand_id & submitted_id > 0".

Or just create a second table such as

brand_x_store
--------------
store_id
brand_id

where brand_id would be:
brand 1 = 1
brand 2 = 2
[...]

View Replies !
Check If Table Exsists
Am creating an install.php page to create the tables for a database. After running the code I want to make sure the tables were created, how do you check is a table exsists in mysql?

View Replies !
Check Existing Values
In my web site I'm using PHP, & MySQL.
There its needed if a user is trying to be registerd using a existing user ID.
That is I think, it should check such a value existing and if exists it must display "Existing User ID".

View Replies !
Check If A Table Exists
is there any way to check if a table exists in mysql? i am using a graph program in vb, but if the table it is trying to graph doesnt exist it breaks down! i need some sort of check so as the offending table will not be added to the query if it doesnt exist?

View Replies !
Check Existience Of Records
I'm trying to find out if something exists in table A *or* table b,

SELECT tableA.user, tableB.user FROM tableA, tableB WHERE tableA.user = 'someuser' OR tableB.user = 'someuser'

But that returns an empty results, even though I know that the user exists in tableA.

View Replies !
Using Trigger To Check Duplicate
I am currently using MySQL 5.0 Query Browser and i would like to create trigger within the browser. Here's my code

Code:

CREATE TRIGGER check_OrderID BEFORE INSERT ON DELIVERY
FOR EACH ROW
BEGIN
IF(orderID!=NEW.OrderID)
THEN
INSERT INTO DELIVERY(DeliveryID,OrderID,DriverID,DeliveryVID)
VALUES(NEW.DeliveryID,NEW.OrderID,NEW.DriverID,NEW.DeliveryVID);
END;

Actually I want to check if the OrderID to be inserted is already in the Delivery table, then that insertion is to ba aborted, if not, it will just continue with the insertion.

View Replies !
Check Username Case
I have a query about checking the case of a username.

If i have a username TEST, if i enter in TEST or test the result from sql is true. I can check it in the program itself but is there a way to do it in SQL.

View Replies !
Performance :: Check Status
I have problems with mysql-performance. When I check "Status", there is written: 23% of all questions are "change db". What does it mean? Select Task are only 13%. Could this be the reason of performance problems?

View Replies !
Check For A Trigger Existence
how i can check to see whether a trigger exists and if it exists then delete it ?
can some one provide an example sql code for this ?

View Replies !
How To Check For Errors In MySQL?
How do you check for errors in the MySQL database? The MySQL database on my site works, but frequently causes the server to crash.

I wanted to know what errors it has. How can I check it? Is their a MySQL validator like their is an RSS Validator or a Java Validator?

View Replies !
How To Check If A DB AND Table Exists
I am trying to do is create some code which will allow me to check if a table of a certain name exists in a database. If the table DOES exist, then I want the code to then insert values into the table. If the table does not exist, then the table should be created, and then the values entered.

I am trying to make it as automated as possible, with a minimum of user involvement as possible.

here is my code so far;

<?php

$username=1;
$punishment=2;
$offence=3;
mysql_connect(localhost, root, panda);

if exists(SELECT * FROM information_schema.tables WHERE table_name = 'naughtylist')

{
insert into naughtylist (username, offence, punishment) VALUES ('$username','$offence','$punishment');
}

[else

begin {

CREATE TABLE `naughtylist`.`watchlist` (
`username` VARCHAR(16) NOT NULL,
`offence` TEXT NOT NULL,
`punishment` TEXT NOT NULL,
PRIMARY KEY (`username`)
)
ENGINE = InnoDB;

insert into naughtylist (username, offence, punishment) VALUES ('$username', '$offence', '$punishment')

]
}
end

?>

View Replies !
Check To See If Database Exists
i'd like to do a quick check to see if a Database exists. i know i can do this:

DROP DATABASE IF EXISTS `databaseName`

but how do i return just whether or not it exists?

View Replies !
Query To Check Space Used
SELECT TABLE_NAME as 'Name table', TABLE_ROWS as 'NB lines',ROW_FORMAT as 'Format Table' . , Max_data_length as 'Max_Data_Length', Data_length as 'Data_Length'....

View Replies !
How To Check If SQL Is Configured Correctly
I am a newbie to mySQL and need help setting it up on my Mac. I downloaded mySQL and have it running, but when I have a PHP action file that calls to my mySQL databases, I am not getting any response. How do I make sure that mySQL is communicating with PHP?

View Replies !
Check Table For An Entry?
I'm currently working on some rudamentry administration, namely an IP ban list. I want to make it so that if the user trys to ban an IP that is already in the list, the entry will be removed instead. what would be the best way to go about this?

View Replies !
Check If A Table Has Been Updated
I'd like to find a way to check if any modifications has been made to a table. I'm using mysql 4.1. I'm trying to find the least resource intensive method of doing this.

View Replies !
Implementing The CHECK Clause`
I am working with mySQL version 4.1.14-max on an Apple Mac. I have been tring to finish up a homework assignment to create the following domain:

CREATE DOMAIN Id INTEGER CHECK ( VALUE > 999 AND VALUE < 99999);

and can't seem to get it to work. I also try addeding the CHECK clause directly into the table, which worked. But, the table is not enforcong the range requierments. After searching the web, I found that mySQL will parse and ignore the CHECK clause when used with CREATE TABLE. So, I have no idea how to restricted the range on the Id attribute.

View Replies !
Programmatically Check Values
I'm completely new within MySQL. I've just used Microsoft Access. Right now, I have to develop a database to store a lot of data. I've heard that it is possible to consult these data with the internet explorer programming a webpage with PHP. Is there some example about it? Is this PHP free to download? Where can I get it?

View Replies !
How To Check Permissions On Tables
I'm developing in Groupware (a php / template-based tool for making office-like applications). It creates mysql tables as it goes. I am not seeing those tables being created, and I'd like to determine if it's a permissions problem.

I'm in a shell on a Linux system, but I'm very unfamiliar with Linux command line.
So far, I can logon as root, use database, show tables; (this is how I know my tables aren't there.)

So, what can I do to ensure that my permissions are set up correctly? When I was setting permissions in the Linux directories, I used 'chown'.

View Replies !
How Do I Check For Missing Records?
I have nearly 10,000 records in my database so it would be impossible to check to see if all of the records are in the database if I checked by hand. I have an integer field in my db called Lnum which I created using excel. The purpose of the Lnum field was to give me a reference and numbering field in the spreadsheet work.

I carried the Lnum field over into the db. The Lnum field has integers numbered for the most part sequentially. A few numbers are repeated. What I want to check for is whether there are any missing records in the database by checking to make sure there are no numerical gaps between Lnum = 1 and Lnum = 99,500.

If there is a numerical gap in the Lnum sequencing, this means I have a missing record or records. Is there a way to use the Lnum field to find missing records, possibly by adding an incrementally numbered field?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved