473,480 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

what will be the function for this

Hi,
I am unable to find the proper function to get the following.
I have 2 cells with date and time in a table. I have to check if the
combination of given date & time exists in the table before a new record is
inserted.
Any idea what function will do this?

Ashok.
Jul 17 '05 #1
3 1551
Hello!
I am unable to find the proper function to get the following.
I have 2 cells with date and time in a table. I have to check if the
combination of given date & time exists in the table before a new record is
inserted.
Any idea what function will do this?


I assume you are speaking about a DB table.
Try to check whether the resultset you get when querying the DB with
SELECT * FROM myTable WHERE (date = given_date) AND (time = given_time);

If the resultset is empty there is no such record.

Perhaps you want to use a PRIMARY KEY(date, time).

Greets,
Hero Wanders
Jul 17 '05 #2
Hero Wanders wrote:
Hello!
I am unable to find the proper function to get the following.
I have 2 cells with date and time in a table. I have to check if the
combination of given date & time exists in the table before a new record is
inserted.
Any idea what function will do this?


I assume you are speaking about a DB table.
Try to check whether the resultset you get when querying the DB with
SELECT * FROM myTable WHERE (date = given_date) AND (time = given_time);

If the resultset is empty there is no such record.


If it's MySQL, "REPLACE INTO" and proper keys will do it
automatically.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

Jul 17 '05 #3
NC
Ashok wrote:

I have 2 cells with date and time in a table.
Why? You should have ONE field of DATEIME type.
I have to check if the combination of given date & time exists
in the table before a new record is inserted.


You absolutely don't have to check it. Create a unique
index on the DATETIME field suggested above (or, if you
insist on keeping your awkward two-field combination,
a single index on both date and time fields). Then you
can INSERT all you want, no duplicates will be allowed;
include the IGNORE keyword, if you want to suppress error
messages.

Cheers,
NC

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
3235
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are...
3
1770
by: Brett | last post by:
What is the following code doing? I see evt and event but what is the difference? <input type="radio" id="us_countryFlag1" name="us_country" onclick="togglePurDec(event)">Yes <script>...
4
2438
by: atv | last post by:
Whatis the proper way to handle errors from function calls? For example, i normally have a main function, with calls to mine or c functions. Should i check for errors in the functions called...
51
4446
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
9
2205
by: AFN | last post by:
I was just dropped into someone else's code (isn't that always so fun?). I can't figure out why a custom validation control's server event function is executing. There is nothing (that I see)...
8
2458
by: johnsonholding | last post by:
Here is the code for a pop-up window that works in Firefox and not in IE - I get a java error or something, Here is the code : </script> <SCRIPT language="JavaScript"...
669
25364
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
4
6668
by: grizggg | last post by:
I have searched and not found an answer to this question. I ran upon the following statement in a *.cpp file in a member function: static const char * const pacz_HTMLContentTypeHeader =...
1
2381
by: td0g03 | last post by:
Hello, I am new to C and I am new to English. I not sure what palindromes mean. I don't know exactly what my teacher wants me to do. If someone could explain it to me in a different way that would be...
16
2324
by: Virtual_X | last post by:
if we use char in a function parameter like that void st(char x) {cout << x;} and char* as a parameter in the same function instead of char x what would be different in my experiments i...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7060
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6760
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7022
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3013
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3004
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.