Announcements
 Crystal Reports Forum : General Information : Announcements
Message Icon Topic: [MySQL] Subquery returns more than 1 row Post Reply Post New Topic
Author Message
les1
Newbie
Newbie
Avatar

Joined: 11 Jan 2012
Online Status: Offline
Posts: 3
Quote les1 Replybullet Topic: [MySQL] Subquery returns more than 1 row
    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
IP IP Logged
sgtjim
Newbie
Newbie
Avatar

Joined: 23 Aug 2011
Online Status: Offline
Posts: 32
Quote sgtjim Replybullet 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"
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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>
IP IP Logged
les1
Newbie
Newbie
Avatar

Joined: 11 Jan 2012
Online Status: Offline
Posts: 3
Quote les1 Replybullet 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
IP IP Logged
les1
Newbie
Newbie
Avatar

Joined: 11 Jan 2012
Online Status: Offline
Posts: 3
Quote les1 Replybullet 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
IP IP Logged
Ankit89
Newbie
Newbie


Joined: 24 Apr 2012
Location: India
Online Status: Offline
Posts: 2
Quote Ankit89 Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.062 seconds.