Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 577833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:11:45+00:00 2026-05-13T14:11:45+00:00

I have got two table create table t1(cid int, isnews int) create table t2(nid

  • 0

I have got two table

create table t1(cid int, isnews int)

create table t2(nid int,cid int, isnews int)

situations is like this:
if t2 contain t2.cid = t1.cid then the t2.isnews = t1.news and
if t2 not contain cid of t1 then new record should be inserted in t2 and that t1.cid, t1.isnews should be inserted in t2..

and complete table should be done in single query… i have done the updation part but not able to do insertion part..

update query:

 UPDATE    t22
SET       t22.isnews = t11.isnews 
FROM      t2 AS t22
    JOIN  t1 AS t11
    ON  t11.cid= t22.cid

i have prepared below cursor for insert… is it good? :

DECLARE @clntid INT
DECLARE @clntnewsltr INT
DECLARE clientnews CURSOR FOR 
SELECT clientid,newsLetter 
FROM clients 
WHERE clientid NOT IN (SELECT clientid FROM clientprivacy) 

OPEN clientnews  
FETCH NEXT FROM clientnews INTO @clntid,@clntnewsltr  

WHILE @@FETCH_STATUS = 0  
BEGIN  

   INSERT INTO clientprivacy (clientId,tdNewsLetters) VALUES(@clntid, @clntnewsltr)
 FETCH NEXT FROM clientnews INTO @clntid,@clntnewsltr  
END  

CLOSE clientnews  
DEALLOCATE clientnews
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:11:46+00:00Added an answer on May 13, 2026 at 2:11 pm

    I think this is the kind of thing you’re after:

    --INSERT t2 (cid, isnews)
    SELECT t1.cid, t1.isnews
    FROM t1
        LEFT JOIN t2 ON t1.cid = t2.cid
    WHERE t2.cid IS NULL
    

    I’ve commented out the INSERT line – I recommend you run the SELECT on it’s own first to check it does give you the correct result (all records from t1 that don’t have a matching cid in t2).

    I’ve assumed t2.nid is an IDENTITY column.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 314k
  • Answers 314k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This should do what you want: $("a.link").click(make_ajax); function make_ajax() {… May 13, 2026 at 11:05 pm
  • Editorial Team
    Editorial Team added an answer Automate Word. If you are using .NET, add Microsoft.Office.Interop.Word (make… May 13, 2026 at 11:05 pm
  • Editorial Team
    Editorial Team added an answer You should be able to replace the default help mechanism… May 13, 2026 at 11:05 pm

Related Questions

I have the following table: CREATE TABLE `events` ( `evt_id` int(11) NOT NULL AUTO_INCREMENT,
I have got a problem with two tables: CREATE TABLE IF NOT EXISTS `addresses`
@Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Problem { @ManyToOne private Person person; } @Entity
I haven't solved this issue by using the stored procedure, yet we've decided to
For example I have the following tables resulting from: CREATE TABLE A (Id int,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.