Welcome Guest, Not a member yet? Register   Sign In
Check if a value exist i a query
#3

[eluser]Quaotloa[/eluser]
I know how to use active records to create arrays, I mean the function NOT IN or IN - is there a build in function in active records to do that? Compares to querys..

Like
"$query = SELECT groupid FROM user_group WHERE groupid NOT IN(”.
“SELECT groupid FROM user_group WHERE userid = $userID)"


I tried to do what you suggested.. My query look like this now:

"$result = $this->db->query("SELECT SUM(pris), timeregid FROM timereg_utlegg WHERE timeregid IN(".
"SELECT timeregid FROM timereg WHERE brukerid = '$brukerid' AND dato_strtotime_format > '$sist_dato_for_lonning')");
"

I get this error
"
A Database Error Occurred

Error Number: 1140

Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

SELECT SUM(pris), timeregid FROM timereg_utlegg WHERE timeregid IN(SELECT timeregid FROM timereg WHERE brukerid = '22' AND dato_strtotime_format > '1248991200')
"

How can I rewrite the query to be correct for codeigniter? It works in original PHP


Messages In This Thread
Check if a value exist i a query - by El Forum - 08-23-2009, 07:19 AM
Check if a value exist i a query - by El Forum - 08-23-2009, 07:25 AM
Check if a value exist i a query - by El Forum - 08-23-2009, 07:32 AM
Check if a value exist i a query - by El Forum - 08-23-2009, 07:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB