473,386 Members | 2,042 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,386 software developers and data experts.

returning results in rows

Ken
I have a db with the fields Day, Month, Year and Message. How can I select
all of the messages for the current week starting with sunday and return the
results as a list?

Thanks
Ken
Jul 19 '05 #1
2 1417
By using a SELECT query. What part are you stuck on? How far have you
gotten so far?

Ray at work

"Ken" <kl*****@spamfreeingr.com> wrote in message
news:OU*************@TK2MSFTNGP11.phx.gbl...
I have a db with the fields Day, Month, Year and Message. How can I select
all of the messages for the current week starting with sunday and return the results as a list?

Thanks
Ken

Jul 19 '05 #2
What kind of database are you using???

Why did you separate day, month and year? It's fine if your date ranges
never cross month or year boundaries, but you're going to have a hard time
querying a range like 2003-12-26 -> 2004-01-03.

Bad column name choices too, by the way. Three of your four columns are
reserved words.

Anyway. You can't reliably get a list from a set of columns, as this
violates set theory. (Databases are used to store sets of data. If you are
not storing sets, but rather lists, just use a flat file.) Granted, there
are ways to do it, but this is better handled in the application.

First, you have to figure out when Sunday was, then return a set of ROWS
that fall in that category.

sunday = dateadd("d", 1-datepart("w", date()), date())
sunday = year(sunday) & "-" & month(sunday) & "-" & day(sunday)
sql = "SELECT [day], [month], [year], message FROM sometable WHERE CDate("'"
& [year] & "-" & [month] & "-" [day] & "'") >= CDate('" & sunday & "')"
set rs = conn.execute(sql)

Then, use ASP to translate the rows into a list,

thislist = ""
prevday = -1
do while not rs.eof
if rs(0) <> prevday then
response.write thislist & "<p>"
prevday = rs(0)
response.write rs(2) & "-" & rs(1) & "-" & rs(0) & ":"
thislist = rs(3)
else
thislist = thislist & ", " & rs(3)
end if
rs.movenext
loop
response.write thislist & "<p>"


"Ken" <kl*****@spamfreeingr.com> wrote in message
news:OU*************@TK2MSFTNGP11.phx.gbl...
I have a db with the fields Day, Month, Year and Message. How can I select
all of the messages for the current week starting with sunday and return the results as a list?

Thanks
Ken

Jul 19 '05 #3

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

Similar topics

8
by: san | last post by:
Hi, I wanted to know if this is possible and if so, how do I do it. Say, I have a query "SELECT * FROM Table WHERE Column="some_value". This executes on a very large data set and I would like...
1
by: Phil Sandler | last post by:
Hello, Quick, and possibly strange, question. I am doing some work testing the running time of some dynamic SQL statements on a remote machine. What I would like to do is execute the SQL on...
9
by: Rowland Hills | last post by:
I have a table which is returning inconsistent results when I query it! In query analyzer: If I do "SELECT * FROM TABLE_NAME" I get no rows returned. If I do "SELECT COL1, COL2 FROM...
3
by: StraightEight | last post by:
Hi, I'm am looking for a little help. I need to create a SQL view which joins a few tables, and I need to return an average for a particular column where a second duplicate ID exists... Heres...
0
by: colinhumber | last post by:
I'm having some issues with my full text indexes in MySQL 3.23.58. I'm using I have a table with a full text index on the 'content' column. There are some words that are returning results just fine...
5
by: Wael | last post by:
Hi, I have the following stored procedure that does some processing and puts the result in a temporary table. I tried several things that procedure to display output that I can access with...
2
by: mokazawa1 | last post by:
Hi, I'm using stored procedures in DB2 UDB 8.1.2. In this stored, I execute a select for update command, opening a cursor. Then I update the rows using fetch and current of. The problem is that...
13
by: Karl Groves | last post by:
I'm missing something very obvious, but it is getting late and I've stared at it too long. TIA for responses I am writing a basic function (listed at the bottom of this post) that returns...
1
by: mbewers1 | last post by:
Hi there, I'm having a strange problem whereby I can execute a select query in Oracle SQL Developer that rerturns some rows but, when this same query is placed into C#, I get no results. I've...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.