New Table creation using SQL

Local time
Today, 23:01
Joined
Mar 6, 2008
Messages
31
How would I archive all orders place by customer 'x' in to a new table called tblArchive?

something like:

CREATE INDEX tblArchive ON tblCustomers WHERE customername = "x" ?
 
Also, on a Parts table, I need to increase all parts whose description includes the word "washer" by 4%

Is this correct:

UPDATE tblParts
SET Price = Price*1.04
WHERE Description LIKE "%washer"

I'm usually wrong about these things!!
 
Going back to the top one . . .

would it be . . .

CREATE TABLE tblArchive ON tblCustomers WHERE customername = "x" ?
 
Going back to the top one . . .

would it be . . .

CREATE TABLE tblArchive ON tblCustomers WHERE customername = "x" ?

No, a CREATE TABLE statement is used to create an empty table.

You need a make table query

Code:
SELECT tblCustomers.* INTO tblArchive FROM tblCustomers 
WHERE tblCustomers.customername = "x";
 
Also, on a Parts table, I need to increase all parts whose description includes the word "washer" by 4%
...snip...
UPDATE tblParts
SET Price = Price*1.04
WHERE Description LIKE "%washer"

You need to put your wildcard on both sides of "washer". If you are using SQL92 for Microsoft databases, it would be '%washer%'. This would include the records for "Fred's magnificent washer" and "A magnificent washer manufactured by Fred", and even, "washer - Fred's best". There is potentially some danger of changing records you don't intend, but it doesn't seem like too big a deal.

Regarding your other post about the 3 (whatevers), that sounds very subjective and really depends on what your professor told you in class or in the text book.
 

Users who are viewing this thread

Back
Top Bottom