473,324 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to generate data sequences?

Hello,

I have a table containing integer counters associated with particular
datetime like this:

CREATE TABLE `counters` (
...
`when` datetime NOT NULL default '0000-00-00 00:00:00',
`counter` smallint(5) unsigned NOT NULL default '0',
...
);

For some purposes I need to initialize frequently the table for time
sequences with constant time step e.g. since 2003-11-06 8:00 to
2003-11-06 12:00 with time step 15 minutes. It means I need to do
following INSERT commands:

INSERT INTO couters (..., '2003-11-06 8:00', 0, ...);
INSERT INTO couters (..., '2003-11-06 8:15', 0, ...);
INSERT INTO couters (..., '2003-11-06 8:30', 0, ...);
....
INSERT INTO couters (..., '2003-11-06 12:00', 0, ...);

Of course my C code is able to generate such command strings in one
simple loop and send them to the MySQL server. But the code should be
as fast as possible and I prefer to do this task by one INSERT-SELECT
command like this:

INSERT INTO counters SELECT ...

Unfortunately I do not have any idea how to build such SELECT command
that will generate the datetime sequence for me. Does anybody know how
to do it? I would appreciate any hints very much.

Thanks, Petr
Jul 19 '05 #1
0 1773

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

Similar topics

7
by: Matthias Czapla | last post by:
Hi! Whats the canonical way for handling raw data. I want to read a file without making any assumption about its structure and store portions of it in memory and compare ranges with constant...
0
by: Petr Matousek | last post by:
Hello, I have a table containing integer counters associated with particular datetime like this: CREATE TABLE `counters` ( ... `when` datetime NOT NULL default '0000-00-00 00:00:00',...
15
by: John Cassidy | last post by:
This has been driving me crazy. I've done basic C in school, but my education is mainly based on object oriented design theory where Java is our tool. For some reason, while helping a friend with a...
6
by: chiara | last post by:
Hi everybody! I am just at the beginning as a programmer, so maybe this is a stupid question...Anyway,I need to write a function in C to generate generate all possible strings of given length...
12
by: Jim Michaels | last post by:
I need to generate 2 random numbers in rapid sequence from either PHP or mysql. I have not been able to do either. I get the same number back several times from PHP's mt_rand() and from mysql's...
9
by: Robert Mago | last post by:
Is there a way to create a 10 characthers or less, alph-numeric string which is unique. I can't use the guid since its longer then 10 characthers. Also i cannot use a random number, since being...
111
by: Nate | last post by:
Hello, I am looking for a method to automatically declare variables in C. I'm not sure if there is a good way to do this, but I had something like this in mind... int i; for(i = 1; i < 4;...
8
by: Marc | last post by:
Hi all, I have to generate and send to a printer many 6 digit alphanumeric strings. they have to be unique but I cannot check in a database or something like that if it have already been printed....
6
by: python | last post by:
I need to generate multi-level incrementing labels for an outline/hierarchy where the string for each level of a label is based on an incrementing sequence like 1, 2, 3 or A, B, C, or even I, II,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.