Sagewire Logo

Subquery returns more than 1 row

8 Message(s) by 2 Author(s) originally posted in mysql discussion


From: UKuser Date:   Monday, October 22, 2007
Hi,

What am I doing wrong with this statement?

UPDATE company
SET new_test =
concat_ws(
(
Select Property from `properties` where `Company_ ID`=1
)
,'#')
WHERE
company.`Company_ ID`=1

I want it to insert Property into the field new_test separated by a #
but it error s on me.

Any help'd be great.

Thanks

A


From: Captain Paralytic Date:   Monday, October 22, 2007
wrote in message:
Hi,
What am I doing wrong with this statement?
UPDATE company
SET new_test =
concat_ws(
(
Select Property from `properties` where `Company_ ID`=1
)
,'#')
WHERE
company.`Company_ ID`=1
I want it to insert Property into the field new_test separated by a #
but it errors on me.
Any help'd be great.
Thanks
A



"it errors on me"
Wow, how bl**dy useful. If my crystal ball was working I could of
course see what error you were getting. But it is not.

So,'d you care to tell us!


From: UKuser Date:   Monday, October 22, 2007
wrote in message:
wrote in message:
> Hi,
> What am I doing wrong with this statement?
> UPDATE company
> SET new_test =
> concat_ws(
> (
> Select Property from `properties` where `Company_ ID`=1
> )
> ,'#')
> WHERE
> company.`Company_ ID`=1
> I want it to insert Property into the field new_test separated by a #
> but it errors on me.
> Any help'd be great.
> Thanks
> A
"it errors on me"
Wow, how bl**dy useful. If my crystal ball was working I could of
course see what error you were getting. But it is not.
So,'d you care to tell us!



"Subquery returns more than 1 row " is the error :o)


From: Captain Paralytic Date:   Monday, October 22, 2007
wrote in message:
Hi,
What am I doing wrong with this statement?
UPDATE company
SET new_test =
concat_ws(
(
Select Property from `properties` where `Company_ ID`=1
)
,'#')
WHERE
company.`Company_ ID`=1
I want it to insert Property into the field new_test separated by a #
but it errors on me.
Any help'd be great.
Thanks
A



Well, for a start, why are you using CONCAT_WS rather than CONCAT?
Next, are you sure that `Company_ ID` is really the column name
(spaces in column names aren't a good idea)?
Next, why should not the subquery return more than one row?


From: UKuser Date:   Monday, October 22, 2007
wrote in message:
wrote in message:
> Hi,
> What am I doing wrong with this statement?
> UPDATE company
> SET new_test =
> concat_ws(
> (
> Select Property from `properties` where `Company_ ID`=1
> )
> ,'#')
> WHERE
> company.`Company_ ID`=1
> I want it to insert Property into the field new_test separated by a #
> but it errors on me.
> Any help'd be great.
> Thanks
> A
Well, for a start, why are you using CONCAT_WS rather than CONCAT?
Next, are you sure that `Company_ ID` is really the column name
(spaces in column names aren't a good idea)?
Next, why should not the subquery return more than one row?



I want it to return every corresponding row and insert it into my new
field. And unfortunately yes Company_ ID is the correct name.
As it stands it only inserts 1 of the fields into my new field rather
than however many are returned by the SELECT statement.


From: Captain Paralytic Date:   Monday, October 22, 2007
wrote in message:
"As it stands it only inserts 1 of the fields into my new field rather
than however many are returned by the SELECT statement."

Your select statement only contains 1 field.


From: Captain Paralytic Date:   Monday, October 22, 2007
wrote in message:
wrote in message:
wrote in message:
> > Hi,
> > What am I doing wrong with this statement?
> > UPDATE company
> > SET new_test =
> > concat_ws(
> > (
> > Select Property from `properties` where `Company_ ID`=1
> > )
> > ,'#')
> > WHERE
> > company.`Company_ ID`=1
> > I want it to insert Property into the field new_test separated by a #
> > but it errors on me.
> > Any help'd be great.
> > Thanks
> > A
> Well, for a start, why are you using CONCAT_WS rather than CONCAT?
> Next, are you sure that `Company_ ID` is really the column name
> (spaces in column names aren't a good idea)?
> Next, why should not the subquery return more than one row?
I want it to return every corresponding row and insert it into my new
field. And unfortunately yes Company_ ID is the correct name.
As it stands it only inserts 1 of the fields into my new field rather
than however many are returned by the SELECT statement.- Hide quoted text -
- Show quoted text -



I have a feeling that you are looking for GROUP_CONCAT()


From: UKuser Date:   Monday, October 22, 2007
wrote in message:
wrote in message:
wrote in message:
wrote in message:
> > > Hi,
> > > What am I doing wrong with this statement?
> > > UPDATE company
> > > SET new_test =
> > > concat_ws(
> > > (
> > > Select Property from `properties` where `Company_ ID`=1
> > > )
> > > ,'#')
> > > WHERE
> > > company.`Company_ ID`=1
> > > I want it to insert Property into the field new_test separated by a #
> > > but it errors on me.
> > > Any help'd be great.
> > > Thanks
> > > A
> > Well, for a start, why are you using CONCAT_WS rather than CONCAT?
> > Next, are you sure that `Company_ ID` is really the column name
> > (spaces in column names aren't a good idea)?
> > Next, why should not the subquery return more than one row?
> I want it to return every corresponding row and insert it into my new
> field. And unfortunately yes Company_ ID is the correct name.
> As it stands it only inserts 1 of the fields into my new field rather
> than however many are returned by the SELECT statement.- Hide quoted text -
> - Show quoted text -
I have a feeling that you are looking for GROUP_CONCAT()



Many thanks for that

UPDATE company
SET new_test =
(
Select GROUP_CONCAT(Property)
from `properties`
where properties.`Company_ ID`=company.`Company_ ID`
)

Has fixed it



Next Message: Data driven relations browsing


Blogs related to Subquery returns more than 1 row

This website will help you to find out everything you need to know ...
knee ligaments The sims hot date free. boyd company louise bell graves diease urethra play gallery purple crocs/uk f - 4 phantom ii freelancer.com sql subquery clamp on ball mount macromedia dreamweaver training village surf shop pci ...

c limited epocast 1652 topowest triad engineering calgary badan ...
... heal montparnasse hotels pukka electric minibike drinking age 18 21 acid base titration wine traurigkeit nyc department of finance parking tax exemption correlated subquery db2 california fresno online radio repairing yamaha engines ...

i have b2evolution a database design question - i want to store ...
while($row=mysql…) { mysql_query(”something with $row[’id’]..”); } Then you need to be using a table join in a single query Haha… hmm.. I just logged into a machine which runs fortune when you log in. My fortune: If you only have a ...

I ma looking for suggestion I have C program that downloads some ...
Well, the MySQL MO is to see how much nerd rage they can generate without people switching. You have to scream but not leave. SCO, the initial split, the removal of the tarballs, it all flows together. don't forget Area 51, ...

Good morning all We recently upgraded from MySQL 5022-log to MySQL ...
im still getting "SQL/DB Error — [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]" how do I turn off these errors? ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional