Welcome Guest, Not a member yet? Register   Sign In
A sql subquery
#1

[eluser]alvaroeesti[/eluser]
Hello,

I have got this, alright

Code:
$this->db->where('paises.id_pais', $paises);
but that just gets me the id of the country, and I need the name.
or in other wordshow do I do this:
Code:
select nombre_pais from paises where id_pais = $paises






thank you
#2

[eluser]NotDior[/eluser]
I'd do this...it will get you more than what you need, but it will also get you what you need.

$this->db->get_where('paises',array('id_pais'=>$paises));

http://ellislab.com/codeigniter/user-gui...ecord.html
#3

[eluser]alvaroeesti[/eluser]
but that is going to get me all the values of all the columns of the row, and I would want just the name of the country, i think smth like this would do

Code:
$this->db->select('nombre_pais FROM paises WHERE paises.id_pais = $paises');
#4

[eluser]NotDior[/eluser]
In that case I'd use the $this->db->query() command which will allow you to write out the SQL code that you need/want. There's probably another way to do it with active record, but I'm not that familiar with it.

So something like this:

Code:
$sSelectSQL = "select nombre_pais from paises where id_pais = $paises";
$xResult = $this->db->query($sSelectSQL);




Theme © iAndrew 2016 - Forum software by © MyBB