Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "SQL help (updating using a count() in mySQL )"
The subquery worked, just had to add in the tables with FROM in that though.
First time I have user mySQL stored procedures, usually I would have a update, set, from where but mySQL wants the from tables in the update bit
Had to go into the system and add some data under a diff user to test, you know you have been on this site too long when your test users are sockpuppet1, sockpuppet2 etc.
Table A is actually a temp table as well which gets built up with a few selects.
First off I know I am rotten at SQL and have managed to busk it for most of my career.
I am trying to write a stored proc and want to update a column with the count of lines for that condition
update
A a , B b , C c
set
a.count = count(c.id)
where
a.id = b.a_id AND
b.id = c.b_id ;
I get a "Invalid use of group function" error
If I set the line to
a.count = 1
I inserts to the table OK. thanks for any help
Try getting the count in a subquery?
update
A a , B b , C c
set
a.count = (SELECT count(c.id)
where
a.id = b.a_id AND
b.id = c.b_id )
where
a.id = b.a_id AND
b.id = c.b_id
I'm sure somebody will be along with a better idea soon
Leave a comment: