Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

What Is Wrong With This query?

 
   Database Forums (Home) -> mySQL RSS
Next:  Using wildcard criteria in an 'in' statement  
Author Message
kevinjbowman

External


Since: Mar 01, 2006
Posts: 2



(Msg. 1) Posted: Thu Mar 09, 2006 10:17 am
Post subject: What Is Wrong With This query?
Archived from groups: mailing>database>mysql (more info?)

Update garment_details
SET garment_details.blankprice = '1.50'
Where garment_details.GarmentDetailID
in (Select
garment_details.GarmentDetailID
From garment_details
Inner Join colors ON garment_details.ColorID =
colors.ColorID
Where
colors.ColorType = '1' AND
garment_details.GarmentID = 'fol3930r'
)

 >> Stay informed about: What Is Wrong With This query? 
Back to top
Login to vote
Bill Karwin

External


Since: Dec 11, 2005
Posts: 72



(Msg. 2) Posted: Thu Mar 09, 2006 10:42 am
Post subject: Re: What Is Wrong With This query? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"kevinjbowman" wrote in message

> Update garment_details
> SET garment_details.blankprice = '1.50'
> Where garment_details.GarmentDetailID
> in (Select
> garment_details.GarmentDetailID
> From garment_details
> Inner Join colors ON garment_details.ColorID =
> colors.ColorID
> Where
> colors.ColorType = '1' AND
> garment_details.GarmentID = 'fol3930r'
> )

It would be helpful when posting question if you would include details about
your environment and the symptoms of any error.
For instance, is this query causing an error? What is the error?
Or does it function correctly, but too slowly?
Or do you just want to know if it's good SQL coding style?

My guess is that you're using MySQL 4.0 or earlier, which doesn't support
subqueries. If so, you're getting a syntax error near where the "(Select"
subquery begins.

If you're using at least 4.0.4, you can try this instead:

UPDATE garment_details g INNER JOIN colors c ON g.ColorID = c.ColorID
SET g.blankprice = '1.50'
WHERE g.GarmentDetailID = 'fol3930r' AND c.ColorType = '1';

This uses multi-table update syntax, which is an extension to SQL that MySQL
offers. It isn't standard SQL, but it's very useful.

Regards,
Bill K.

 >> Stay informed about: What Is Wrong With This query? 
Back to top
Login to vote
Display posts from previous:   
   Database Forums (Home) -> mySQL All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]