Subqueries are not allowed in this context. Only scalar expressions are allowed.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ahmedhussain
    New Member
    • Dec 2008
    • 79

    Subqueries are not allowed in this context. Only scalar expressions are allowed.

    I am writing this query but didnt understand why isnt it working...
    Its giving me the error :
    Subqueries are not allowed in this context. Only scalar expressions are allowed.
    Code:
    INSERT INTO [Job] ([User_Id], [Cat_id], [Job_Description], [Job_Status], [JobTitle], [NumberOfPositions], [JobTenure], [ManagementLevel], [JobDuration], [EducationRequired], [Experience], [RequiredTravel], [Salary], [StartDate], [CoverLetterRequirement], [ContactPerson], [EmailAddress], [Closing Date CV], [EmployerName], [EmployerPersonalEmail], [EmployerPhone])
    VALUES ((select ([Job].User_Id) as UserID from Job
    inner join Users ON ([Job].User_Id = [Users].User_Id)
    where [Job].User_Id = '1') , @Cat_id, @Job_Description, @Job_Status, @JobTitle, @NumberOfPositions, @JobTenure, @ManagementLevel, @JobDuration, @EducationRequired, @Experience, @RequiredTravel, @Salary, @StartDate, @CoverLetterRequirement, @ContactPerson, @EmailAddress, @Closing_Date_CV, @EmployerName, @EmployerPersonalEmail, @EmployerPhone)
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    I assume your SELECT will only return a single record. Try this:

    Code:
    
    INSERT INTO [Job] ([User_Id], [Cat_id], [Job_Description], [Job_Status], [JobTitle], [NumberOfPositions], [JobTenure], [ManagementLevel], [JobDuration], [EducationRequired], [Experience], [RequiredTravel], [Salary], [StartDate], [CoverLetterRequirement], [ContactPerson], [EmailAddress], [Closing Date CV], [EmployerName], [EmployerPersonalEmail], [EmployerPhone])
    select ([Job].User_Id) as UserID, @Cat_id, @Job_Description, @Job_Status, @JobTitle, @NumberOfPositions, @JobTenure, @ManagementLevel, @JobDuration, @EducationRequired, @Experience, @RequiredTravel, @Salary, @StartDate, @CoverLetterRequirement, @ContactPerson, @EmailAddress, @Closing_Date_CV, @EmployerName, @EmployerPersonalEmail, @EmployerPhone 
    from Job inner join Users ON ([Job].User_Id = [Users].User_Id)
    where [Job].User_Id = '1'
    Happy Coding!!!

    ~~ CK

    Comment

    • Ahmedhussain
      New Member
      • Dec 2008
      • 79

      #3
      Hi CK

      Sorry my information mislead you ... My mistake... Sorry for that..

      I have two tables one is the "HOST" through which I am going to get the userID and the other is the "JobCategor y" from which I am going to get a job_CategoryID. .. And the rest of the values are going to come from the aspx form.
      I want to insert all the values from the form except the hosts User_ID and Job Category cateogryID, so that I could insert it directly.
      The table I am using to insert the information is the JOB table..

      Can you please help me with that...

      Thanks in advance

      Regards,

      Syed Ahmed Hussain

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        Could you post the structure of your tables or sample data and identify which data would be coming from where?

        Happy Coding!!!

        ~~ CK

        Comment

        Working...