List:General Discussion« Previous MessageNext Message »
From:Colin McKinnon Date:December 30 1999 3:15pm
Subject:Re: Check for record ..
View as plain text  
At 19:02 30/12/99 +0530, mathur wrote:
>I need to check for particular records whether they exist or not
>
>How can I do that ?

Write a query.

But seriously, there isn't enough information to here to make a proper
response. I guess you want to check if a particular record exists and if it
does take some action....

DELETE * FROM orders
WHERE EXISTS (SELECT bad_supplier.id FROM bad_supplier
	WHERE badsupplier.id=orders.supplier_id);

....In which you can't - MySQL didn't support sub-queries last time I
checked. You need to use a programming language to retreive a set of values
then generate a query for each element of the set to get your result.

Unless....you really want to do a join e.g.

SELECT orders.number from orders, order_lines
WHERE orders.id=order_lines.order_id
AND order_lines.item="furby"
GROUP BY orders.number;
 
- this would give you the order numbers for orders which include 'furby'
from a badly designed schema.

HTH

Colin

Thread
Check for record ..mathur30 Dec
  • Re: Check for record ..Fraser MacKenzie30 Dec
  • Re: Check for record ..Colin McKinnon30 Dec
    • Re: Check for record ..mathur31 Dec
      • Re: Check for record ..sinisa31 Dec
      • Re: Check for record ..Don Read31 Dec
    • Re: Check for record ..Jeremy Cole31 Dec
RE: Check for record ..home)3 Jan
  • Re: Check for record ..Benjamin Pflugmann3 Jan
    • Re: Check for record ...Michael Budash3 Jan