If this is your first visit, be sure to check out the FAQ by clicking the link above. You may 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.

 
Go Back  dBforums > Database Server Software > MySQL > Getting more than 1 rows in subquery

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-25-06, 05:38
anjanesh anjanesh is offline
Registered User
 
Join Date: Feb 2005
Location: Mumbai, India
Posts: 161
Getting more than 1 rows in subquery

Code:
SELECT tbl1.`fld1`, (SELECT `fld` FROM `tbl2`) FROM `tbl1` tbl1
says #1242 - Subquery returns more than 1 row

But I want these more-than-one-row values.

How do I get that ?

Thanks
__________________
MySQL 5.1
Reply With Quote
  #2 (permalink)  
Old 06-25-06, 08:41
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
the only way to do what you want is with a cross join:
Code:
select tbl1.fld1
     , tbl2.fld
  from tbl1
cross
  join tbl2
this will give you every value of fld1 in tbl1 with every value of fld in tbl2, which is what your original query would have done if it were legal
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On