Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    161

    Unanswered: 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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •