Print Page | Close Window

[MySQL] Subquery returns more than 1 row

Printed From: Crystal Reports Book
Category: General Information
Forum Name: Announcements
Forum Discription: Please check this section for the latest announcements from Crystal Reports Forum
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=15342
Printed Date: 28 Apr 2024 at 9:27pm


Topic: [MySQL] Subquery returns more than 1 row
Posted By: les1
Subject: [MySQL] Subquery returns more than 1 row
Date Posted: 11 Jan 2012 at 4:09am
Hi everyone,

I'm newbie in using crystal report and now I have a problem with it. I used this SQL expression

(SELECT bk_cat FROM tbl_bk GROUP BY bk_cat ORDER BY bk_cat)

but this error occurred "Error in compiling SQL Expression: Query Engine Error: 'HY000:[MySQL][ODBC 5.1 Driver][mysqld-5.5.8]Subquery returns more than 1 row'."

I just want to list all the distinct strings. I hope you understand my problem. Any suggestion would be appreciated.

PS
Sorry for my bad English.

-------------


les



Replies:
Posted By: sgtjim
Date Posted: 11 Jan 2012 at 9:02am
Try this

Select
Max(bk_cat)
From
tbl_bk
Where
tbl_bk."linking field" = "table in report"."linking field"


Posted By: BrianBischof
Date Posted: 12 Jan 2012 at 5:17pm
You can also try

SELECT DISTINCT bk_cat FROM tbl_bk ORDER BY bk_ca


Brian

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: les1
Date Posted: 13 Jan 2012 at 9:08pm
Originally posted by sgtjim

Try this

Select
Max(bk_cat)
From
tbl_bk
Where
tbl_bk."linking field" = "table in report"."linking field"


Thanks for reply but it only returns 1 row.

-------------


les


Posted By: les1
Date Posted: 13 Jan 2012 at 9:10pm
Originally posted by BrianBischof

You can also try

SELECT DISTINCT bk_cat FROM tbl_bk ORDER BY bk_ca


Brian



Thank you for reply but it gave me the same error.

-------------


les


Posted By: Ankit89
Date Posted: 24 Apr 2012 at 11:20am
this is default.aspx.cs code ... i have to fetch 1 single row from my database from my table...also i have taken drop down list...and when i m selecting any of the number in drop down ...it is displaying the total tabel attributes which i have selected in the code......here is the code...plse give me correct solution asap......

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    

    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["crmConnectionString"].ConnectionString);
        con.Open();
        string sql1 = "select MP_ID, DOB , Height , Address , Complexion , Gender from Missing_Person where  (MP_ID = 3 AND First_Name='Ravi') ";
        SqlDataAdapter da = new SqlDataAdapter(sql1,con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        ReportDocument rep_doc = new ReportDocument();
        rep_doc.Load(Server.MapPath("~/FirReport.rpt"));
        rep_doc.SetDataSource(ds.Tables[0]);
        CrystalReportViewer1.ReportSource = rep_doc;
        //Following Statements are Optional
        CrystalReportViewer1.DataBind();
        CrystalReportViewer1.RefreshReport();
    }
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {

    }
   
}


//" i only want one 1 row attributes to b fetch from database and to b displayed'//


-------------
Ankit



Print Page | Close Window