English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories
0

i have a table.it contains column named tel_hp.so, i want to correct the tel_hp records; which the tel_hp has less number from the standard or more number from the standard or the tel_hp which has the dash character (-).
then from that query and records amendment, i want to put it into a new table.
does anybody know what is the sql command for it?
thanks...

2006-11-07 11:34:56 · 4 answers · asked by kakashi 1 in Computers & Internet Programming & Design

4 answers

Assuming you are on Oracle DB (why not, about 80-90% are)...

This should try and help you:

SELECT * FROM YOURTABLE WHERE LENGTH(TEL_HP) <> SOMENUMBER;

The above should give you a list of rows where TEL_HP is NOT EQUAL to the character length you are looking for.

From there you can nest that into an INSERT statement after you create a similar table.

Example,

INSERT INTO NEWTABLE (SELECT * FROM YOURTABLE WHERE LENGTH(TEL_HP) <> SOMENUMBER)

2006-11-07 11:56:51 · answer #1 · answered by George S 3 · 0 0

create table amendment select * from table_original where tel_hp not like '104724729' or tel_hp like '%-%'

grant all on amendment to public

in the first query what you are doing is selecting all the records which dont match a specific number and putting them into the table amendment.Also the records with tel_hp containing a - are put into the new table.

The second query is to grant access permissions for update,insert,delete,select..everything

2006-11-08 01:39:14 · answer #2 · answered by life goes on... 2 · 0 0

declare @tel_hp as Varchar(255)

declare CursorName cursor scroll for
select tel_hp from Table1
where tel_hp < Standard
Or tel_hp > Standard
Or tel_hp like '%-%'

open CursorName
fetch next from CursorName into @tel_hp
while @@fetch_status = 0
begin
insert onto NewTable(tel_hp)
values(@tel_hp)
fetch next from CursorName into @tel_hp
end
close CursorName
deallocate CursorName

2006-11-07 13:45:56 · answer #3 · answered by safrodin 3 · 0 0

The basic syntax is:

CREATE TABLE new_table
AS (SELECT * FROM old_table);


For example:

CREATE TABLE suppliers
AS (SELECT *
FROM companies
WHERE id > 1000);

Hope this helps, I am not 100% sure what you are looking for. But I think this is it...


Enjoy -

2006-11-07 11:43:04 · answer #4 · answered by Chris 2 · 0 0

fedest.com, questions and answers