Query question....

  • Hi all. I need to do the following:

    delete from sysuser_webpage suwp, webpage wp

    where suwp.sysuser_id = '2'

    and suwp.webpage_uuid = wp.webpage_uuid

    and wp.state_code IN ('CT', 'NH')

    Obviously the first line tosses a syntax error. Can anyone explain how I can accomplish the above query? I'm just deleting from the sysuser_webpage table, but need comparison conditionals met which are in webpage table. Any thoughts? Thanks in advance!

  • Try this:

    delete sysuser_webpage

    where sysuser_id = '2'

    and webpage_uuid in(

     select webpage_uuid

     from webpage

     where state_code in('CT','NH'))

    /rockmoose


    You must unlearn what You have learnt

  • Ahh sweet mother of meat. Works great, thanks moose!

  • Or this way

    delete suwp

    from sysuser_webpage suwp

    inner join webpage wp

    on wp.webpage_uuid = suwp.webpage_uuid

    and wp.state_code IN ('CT', 'NH')

    where suwp.sysuser_id = '2'

    sometimes joins run better than using IN depending on volume etc.

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply