To insert the mailid in the specific id postion?

to enter the mail id in id no 1 and 2 and specific number what is the query?

insert into sample where id=1 (Emailid)values('ajxavier8@gmail.com')  is this a wrong query

id       name     occupaton    num      status       condition   mailid

1 aqibjavid Engineer 564654 single Health NULL
3 xavier doctor 455664 married good          NULL
4 NULL NULL NULL NULL NULL ajxavier8@gmail.com

August 29th, 2015 3:48am

Hi Xaavier8,

Based on your description, are you looking for a UPDATE statement?

CREATE TABLE sampleTBL
(
id INT,
name VARCHAR(20),
occupaton VARCHAR(20),
num INT,
[status] VARCHAR(20),
condition VARCHAR(20),
mailid VARCHAR(20)
);
GO

INSERT INTO sampleTBL 
VALUES
(1,'aqibjavid','Engineer',564654,'single','Health',NULL),
(3,'xavier','doctor', 455664,'married','good',NULL),
(4,NULL,NULL,NULL,NULL,NULL,'ajxavier8@gmail.com')

UPDATE sampleTBL SET mailid='ajxavier8@gmail.com' WHERE ID=1

--For a non-exist row ID=2, you would have to INSERT first
INSERT sampleTBL(ID,mailid) VALUES(2,'ajxavier8@gmail.com');

SELECT * FROM sampleTBL

DROP TABLE sampleTBL

If you have any question, feel free to let me
Free Windows Admin Tool Kit Click here and download it now
August 30th, 2015 9:49pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics