Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Re: Delete from...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 15953 of 16301
Post > Topic >>

Re: Delete from Join

by gwynethm@[EMAIL PROTECTED] (Gwyneth Morrison) Jul 4, 2008 at 10:00 AM

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Tom Lane wrote:
<blockquote cite="mid:2938.1215098986@[EMAIL PROTECTED]
" type="cite">
  <pre wrap="">Gwyneth Morrison <a class="moz-txt-link-rfc2396E"
href="mailto:gwynethm@[EMAIL PROTECTED]
">&lt;gwynethm@[EMAIL PROTECTED]
>
writes:
  </pre>
  <blockquote type="cite">
    <pre wrap="">What I am actually trying to get past is:
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
  <blockquote type="cite">
    <pre wrap="">    DELETE FROM data_table1
                using data_table2 INNER JOIN
                         data_table1  ON data_table1.fkey =
 data_table2.pkey;
    </pre>
  </blockquote>
  <pre wrap=""><!---->
The equivalent to that in Postgres would be

    DELETE FROM data_table1
      USING data_table2
      WHERE data_table1.fkey = data_table2.pkey;

The fundamental issue here is that MSSQL expects the USING clause to
contain a second reference to the delete target table, whereas PG
does not --- if you write the table name again, that's effectively
a self-join and you probably won't get the behavior you want.

You can use JOIN syntax in USING in Postgres, but only for situations
where the query really involves three or more tables.

			regards, tom lane
  </pre>
</blockquote>
Thank you Tom,<br>
<br>
That was exactly what I needed to know and yes it does work.<br>
<br>
I do know about the using/from clause and&nbsp; and the second table
reference.<br>
<br>
Sorry about the above example, I cut it from something much larger to
try and <br>
get my point&nbsp; across. Yes it is invalid. I should be more
careful.<br>
<br>
I do have another question I will post as a separate posting. <br>
<br>
Gwyneth<br>
</body>
</html>
 




 5 Posts in Topic:
Re: Delete from Join
gwynethm@[EMAIL PROTECTED  2008-07-02 15:12:59 
Re: Delete from Join
gwynethm@[EMAIL PROTECTED  2008-07-03 08:26:52 
Re: Delete from Join
tgl@[EMAIL PROTECTED] (T  2008-07-03 11:29:46 
Re: Delete from Join
lennin.caro@[EMAIL PROTEC  2008-07-03 06:28:38 
Re: Delete from Join
gwynethm@[EMAIL PROTECTED  2008-07-04 10:00:14 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 20 8:40:09 CDT 2008.