<p><br /><br />I am new to catalyst and need guidance in fetching some data from my mysql db.<br /><br />I want to know how can I write below queries(1&amp;2)<br /><br /><span style="color: #0000ff;">Here is dummy table structure I am using. </span><br /><span style="color: #0000ff;">-------------------------------------------------</span><br /><span style="color: #0000ff;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;table1</span><br /><span style="color: #0000ff;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;=======</span><br /><span style="color: #0000ff;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;qid&nbsp; sid status name</span><br /><span style="color: #0000ff;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;__PACKAGE__-&gt;set_primary_key("qid");</span><br /><span style="color: #0000ff;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;__PACKAGE__-&gt;belongs_to("queq_dump", 'MYAPP::Schema::Result::Table2, {qid =&gt; 'qid'});</span><br /><br /><span style="color: #0000ff;">-------------------------------------------------</span><br /><span style="color: #0000ff;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;table2</span><br /><span style="color: #0000ff;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pid eid qid name</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; primary_key == pid+qid+eid<br /><span style="color: #0000ff;">-------------------------------------------------</span><br /><br /><span style="color: #339966;">&nbsp;&nbsp; &nbsp;QUERY 1</span><br /><span style="color: #339966;">&nbsp;&nbsp; &nbsp;=======</span><br /><span style="color: #339966;">&nbsp;&nbsp; &nbsp;select A.qid, A.name, A.name from table1 A, table2 B </span><br /><span style="color: #339966;">&nbsp;&nbsp; &nbsp;where </span><br /><span style="color: #339966;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A.qid = B.qid </span><br /><span style="color: #339966;">&nbsp;&nbsp; &nbsp;and&nbsp; A.sid = 1</span><br /><span style="color: #339966;">&nbsp;&nbsp; &nbsp;and&nbsp; B.pid != 2</span><br /><br /><span style="color: #339966;">&nbsp;&nbsp; &nbsp;QUERY 2</span><br /><span style="color: #339966;">&nbsp;&nbsp; &nbsp;=======</span><br /><span style="color: #339966;">&nbsp;&nbsp; &nbsp;select A.qid, A.name, A.name from table1 A, table2 B </span><br /><span style="color: #339966;">&nbsp;&nbsp; &nbsp;where </span><br /><span style="color: #339966;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; A.qid = B.qid and B.eid = (select min(eid) from table2 where table2.status = 1)</span></p>