SQL Subquery Problem

Results 1 to 3 of 3

Thread: SQL Subquery Problem

  1. #1
    New Bee Guest

    Default SQL Subquery Problem

    Is there a rule with the DELETE statement not to mix up table elements as can be done with a SELECT statement, so I must use a subquery as so:<BR><BR>SELECT * <BR>FROM COUNTRY_RECRUITMENT AS CR<BR>WHERE CR.COUNTRY_ID=<BR>AND CR.PROTOCOL_NUMBER=<BR>{<BR> SELECT CD.COUNTRY_ID, CD.PROTOCOL_NUMBER<BR> FROM COUNTRY_DETAIL AS CD<BR> WHERE CD.PROTOCOL_NUMBER=&#039;Protocol&#039;<BR> AND CD.REGION_ID=19<BR>}<BR><BR>If so, then what is the problem with the statement above? The error message I get is: [Microsoft][ODBC SQL Server Driver]Syntax error or access violation<BR><BR>Please advise. Thank you in advance to kind SQL guru respondants.

  2. #2
    Join Date
    Dec 1969

    Default What's with the {}

    I really believe t-SQL doesn&#039;t use { and }, that gives the the syntax error [just use ( and ) ]<BR><BR>But I don&#039;t understand your question, could you be more specific about the DELETE part??<BR><BR>Peter

  3. #3
    New Bee Guest

    Default RE: What's with the {}

    I want to delete a record that requires the process of a WHERE inner join between two tables, so I suspect that a subquery is required to do so. Am I allowed to put a where clause in the DELETE statement to join two tables for the comparison of two fields or does the DELETE statement preclude the WHERE clause from being used at all?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts