Question: I am trying to track pageviews on my site whether a user is logged in or not and so I'm capturing the sessionId in my log. I only want to show tracking results for session ids that have at some point logged in and so my flow is as follows:

```
$pagestats = $wpdb->get_results("SELECT * FROM wp_user_stats WHERE uid=".$_GET['viewstats']);
$sessionArray = array();

foreach($pagestats as $checkSession)
{
    if( !(in_array($checkSession->sessionId, $sessionArray)))
    {
        $sessionArray[] = $checkSession->sessionId;
        }
    }

```

Next, I am trying to gather all of the stats concerning any session Ids generated by this particular user ...

```
$sessions = join(',',$sessionArray);
$pagestats = $wpdb->get_results("SELECT * FROM wp_user_stats WHERE `sessionId` IN($sessions)") or die(mysql_error());

```

This is the part that throws the error. The error is:

```
Unknown column 'sjhntmqhltknks8pbhr750voe7' in 'where clause'

```

I don't understand why it's trying to find a column that matches the session Id instead of a result within that column.

Answer: 
The session IDs probably aren't getting quoted so the query looks like `WHERE sessionID IN(abc, def, ...)`.

One way to fix that would be to change a line in the first loop:

`$sessionArray[] = "'".$checkSession->sessionId."'";`

Or you could create a second array with the quoted values.
I think you need to put quote around your session values

```
$sessions = "'".join("','",$sessionArray)."'";

```

Right now it's like `WHERE IN (a,b,c)` instead of `WHERE IN ('a','b','c')`.