![]() |
Finding Difficulties with some SQL - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Finding Difficulties with some SQL (/showthread.php?tid=8035) |
Finding Difficulties with some SQL - El Forum - 05-02-2008 [eluser]Shahidul[/eluser] Hello I'm a beginner with CI Now in difficulties with some SQL. I want to retrieve data from mysql. the traditional query is like the following. SELECT t.tdl_name, t.tdl_description, t.tdl_author, c.company_name, c.company_address, d.developer_name FROM tdl_info t, company_info c, developer_info d WHERE t.tdl_id = 1 AND c.company_id = t.tdl_id AND d.developer_id = t.developer_id Which retrieve a single row from three tables. tdl_info, developer_info, company_info where tdl_id = 1 from table tdl_info. How to implement this query within CI. Thanks Shahidul Finding Difficulties with some SQL - El Forum - 05-02-2008 [eluser]reset[/eluser] Hello Shahidul, Your query could be that: Code: $this->db->select('t.tdl_name, t.tdl_description, t.tdl_author, c.company_name, c.company_address, d.developer_name'); Finding Difficulties with some SQL - El Forum - 05-02-2008 [eluser]gtech[/eluser] or you can cheat, and just manually write the sql statement. $query = $this->db->query("SELECT t.tdl_name, t.tdl_description, t.tdl_author, c.company_name, c.company_address, d.developer_name FROM tdl_info t, company_info c, developer_info d WHERE t.tdl_id = 1 AND c.company_id = t.tdl_id AND d.developer_id = t.developer_id"); [url="http://ellislab.com/codeigniter/user-guide/database/queries.html"]http://ellislab.com/codeigniter/user-guide/database/queries.html[/url] Finding Difficulties with some SQL - El Forum - 05-03-2008 [eluser]Shahidul[/eluser] Thank you very much for your help. This will help me very much. Thanks again. Shahidl |