1
gruessle
SQL - EXISTS
  • 2003/12/7 1:47

  • gruessle

  • Friend of XOOPS

  • Posts: 348

  • Since: 2003/9/20


The command EXISTS can it be used with UPDATE?

Something like this maybe?

UPDATE products SET status ='0' WHERE products_id=2731 EXISTS;

2
Mithrandir
Re: SQL - EXISTS

in the case you describe, EXISTS is not required.

in other cases, EXISTS is not placed as you do it, more like:
UPDATE products SET status=0 WHERE EXISTS...

but it's mainly used in conjunction with subqueries, which MySQL supports very very badly...
In your example, leaving out the EXISTS will still get the job done - if products_id=2731 doesn't exist, the query will fail or at least return a getRowsNum = 0 - leaving the "EXISTS" clause effectless

----Disclaimer----
I am under the influence of Alcohol at the moment and my IQ is at around room temperature, so if you are offended by my posting, please take this into consideration. Thank you.

Thank you for your interest in my comments
----Disclaimer----

3
gruessle
Re: SQL - EXISTS
  • 2003/12/7 4:50

  • gruessle

  • Friend of XOOPS

  • Posts: 348

  • Since: 2003/9/20


Yes you are right, I had tried this without the EXIST and it worked fine.

Thank you

Login

Who's Online

348 user(s) are online (52 user(s) are browsing Support Forums)


Members: 0


Guests: 348


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits