Question: I have a table that is similar below.

```
     |  user_id  |   point_1  | point_2  | point_3
        453123        1234         32       433
        321543         1           213      321

```

My query is something like this: 

```
$query = "SELECT * FROM my_table WHERE user_id = 12345 OR user_id = 987654321"

```

Obviously, this will return nothing since `user_id` 12345 OR `user_id` 987654321 do not exist on the table.

But I still want to return something like the one below :

```
|  user_id   |   point_1  | point_2  | point_3
    12345           0           0         0
  987654321         0           0         0

```

Answer: 
You could use an inline view as a rowsource for your query. To return a zero in place of a NULL (which would be returned by the outer join when no matching row is found in my\_table, you can use the `IFNULL` function.

e.g.

```
SELECT s.user_id
     , IFNULL(t.point_1,0) AS point_1
     , IFNULL(t.point_2,0) AS point_2
     , IFNULL(t.point_3,0) AS point_3
  FROM ( SELECT 12345 AS user_id
         UNION ALL SELECT 987654321
       ) s
  LEFT
  JOIN my_table t
    ON t.user_id = s.user_id

```

NOTE: If datatype of `user_id` column my\_table is character, then I'd enclose the literals in the inline view in single quotes. e.g. **`SELECT '12345' AS user_id`**. If the characterset of the column doesn't match your client characterset, e.g. database column is latin1, and client characterset is UTF8, you'd want to force the character strings to be a compatible (coercible) characterset... **`SELECT _latin1'12345' AS user_id`**
You can't get the result you want using only a select statement. Only rows that exist somewhere will be returned.

The only way I can think to do this is to insert the query values into a temp table and then outer join against that for your query.

So the basic process would be:

```
create table temp1 (user_id integer);

insert into temp1 values (987654321); -- repeat as needed for query.

select t.user_id, m.* from temp1 t left outer join my_table m on m.user_id = t.user_id;

drop table temp1;

```

This isn't very efficient though.