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 4033202
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:49:08+00:00 2026-05-20T11:49:08+00:00

I have a table SEND with one column Aname : Aname —— GREAME PETER

  • 0

I have a table SEND with one column Aname:

Aname   
------
GREAME  
PETER   

Another table RECEIVE with 2 columns:

Aname                              Permission
-----------------------------------------------
GREAME (copied from table SEND)    'my own value will be inserted here,
                                    specified in insert query'

PETER  (copied from table  SEND)    'my own value will be inserted here,
                                    specified in insert query'

Now as shown above, I want to insert into a new table RECEIVE only the Aname column from table SEND and in the second column I would insert a new value.

Also, I want that no duplicate values could be inserted in RECEIVE table:

I want this:

Aname   Permission
---------------------
GREAME  PLAYER
GREAME  PLAYER --- COULD NOT BE INSERTED
GREAME  SALESMAN   --- COULD BE INSERTED

I am using this query :

insert into receive(Aname, Permission)
  select Aname , 'Select' 
  from SEND
  where not exists
     (select * from RECEIVE where Aname = 'GREAME' and Permission = 'select')

This query takes both the names GREAME & PETER from the SEND table and inserts them into the RECEIVE table, but I want that only GREAME is picked up, not PETER.

How do I do it?

IT TAKES ALL THE ROWS FROM TABLE SEND, and inserts them in table RECEIVE, but I want that only one row gets inserted. So I want the query to be like this but it gives syntax error:

insert into RECEIVE(Aname , Permission)
  select Aname , 'select' 
  from SEND
  WHERE Aname = 'GREAME'  -------------this line gives error
  where not exists
    (select *  from RECEIVE where aname = 'GREAME' and Permission = 'select')
  • 1 1 Answer
  • 0 Views
  • 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-20T11:49:09+00:00Added an answer on May 20, 2026 at 11:49 am

    You can’t have two WHERE clauses in one statement:

    insert into RECEIVE(Aname , Permission)
      select Aname , 'select' 
      from SEND
      WHERE Aname = 'GREAME'   <=== WHERE #1
      where not exists         <=== WHERE #2
        (select *  from RECEIVE where aname = 'GREAME' and Permission = 'select')
    

    You need to change the second part to an AND:

    insert into RECEIVE(Aname , Permission)
      select Aname , 'select' 
      from SEND
      WHERE Aname = 'GREAME'  
      AND not exists
        (select *  from RECEIVE where aname = 'GREAME' and Permission = 'select')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which one column is button, how can I send ${user.key}
I have a CGridView with columns from a table product => {'product_id','category_id',...} I have
I have one column in my table which will store data in string format
i have a stack of messages in database table. i want to send these
I have table rows of data in html being filled from a CGI application.
I have table with 3 columns A B C. I want to select *
i have table unser it i have one td with elemets inside the menu
I have table in data base name train delay, with columns train number(int), DelayTime(int),
I have a table with a number of columns that will be used to
I have a table with several fields and one field having 3 Comma Separated

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.