Welcome Guest, Not a member yet? Register   Sign In
DB Help
#1

[eluser]Jagar[/eluser]
I'm not sure what i'm doing wrong, but it comes out wrong.

I'm trying to query using active record class using the following query:
Code:
$query = $this->db->select("if(status=1,'Enabled','Disabled') as status")->from('admin')->get();
but I get the following error:

Code:
A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as status FROM (`admin`)' at line 1

SELECT if(status=1, `'Enabled'`, `'Disabled')` as status FROM (`admin`)

I'm translating 0 to Disabled and 1 to Enabled

Thanks


Messages In This Thread
DB Help - by El Forum - 04-28-2009, 08:54 AM
DB Help - by El Forum - 04-28-2009, 08:57 AM
DB Help - by El Forum - 04-28-2009, 09:16 AM
DB Help - by El Forum - 04-28-2009, 09:18 AM
DB Help - by El Forum - 04-28-2009, 09:21 AM
DB Help - by El Forum - 04-28-2009, 09:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB