Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - DB query
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

DB query

 Post Reply Post Reply
Author
hack_it View Drop Down
Newbie
Newbie
Avatar

Joined: 16 November 2003
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote hack_it Quote  Post ReplyReply Direct Link To This Post Topic: DB query
    Posted: 16 November 2003 at 2:03pm

i have an orders table and i am tryin to insert these orders into a history table at the end of each day. i'm using an insert select statement.

this is working fine but was wondering how i would enter that days date in a new column in history table for each of those orders so i can tell when order was made???

any help would be great.

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2003 at 2:05pm

Well put a date/time column in your database, then your insert query should be something like:

([date]) VALUES ('" & now() & "')



Edited by Gullanian
Back to Top
hack_it View Drop Down
Newbie
Newbie
Avatar

Joined: 16 November 2003
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote hack_it Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2003 at 2:10pm

INSERT INTO orders_history (ProductID, ProductName, Price, CardNumber, CardType, Expires) SELECT productid, productname, price, cardnumber, cardtype, expires  FROM orders

my insert statement is like this so is there a way of using the values clause as well as the select clause in an insert statement??

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2003 at 2:24pm
INSERT INTO orders_history (ProductID, ProductName, Price, CardNumber, CardType, Expires, [datefield]) SELECT productid, productname, price, cardnumber, cardtype, expires, [datefunction] FROM orders

[datefield] is the field that you want the date value in
[datefunction] is the date function (Now() for Access; getdate() for SQL Server)

You could also set the defautl value for the [datefield] with the [datefunction] so that when a new value is entered into the table the value is already present.

Back to Top
hack_it View Drop Down
Newbie
Newbie
Avatar

Joined: 16 November 2003
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote hack_it Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2003 at 2:36pm

INSERT INTO orders_history (ProductID, ProductName, Price, CardNumber, CardType, Expires, [OrderDate]) SELECT productid, productname, price, cardnumber, cardtype, expires, [Now()] FROM orders

sorry but is this how its done cause it gives me an error saying too few parameters.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.