0

これが私がやっているMySQLです:

mysql> select "Le Café de la Mairie" as titre, "15 pl Mairie" as adresse1, id from ville where sound=soundex('FERTE SOUS JOUARRE') and cp='77260';
+-----------------------+--------------+-----+
| titre                 | adresse1     | id  |
+-----------------------+--------------+-----+
| Le Café de la Mairie  | 15 pl Mairie | 447 |
+-----------------------+--------------+-----+
1 row in set (0.00 sec)

mysql> select "Le Café de la Mairie" as titre, "15 pl Mairie" as adresse1, id from ville where sound=soundex('FERTE SOUS JOUARRE') and cp='77261';
Empty set (0.00 sec)

mysql>

これが私が欲しいものです:

mysql> select "Le Café de la Mairie" as titre, "15 pl Mairie" as adresse1, id from ville where sound=soundex('FERTE SOUS JOUARRE') and cp='77260';
+-----------------------+--------------+-----+
| titre                 | adresse1     | id  |
+-----------------------+--------------+-----+
| Le Café de la Mairie  | 15 pl Mairie | 447 |
+-----------------------+--------------+-----+
1 row in set (0.00 sec)

mysql> **(same query but dont find a record)**;
+--------------+------------+------+
| titre        | adresse1   | id   |
+--------------+------------+------+
| NULL         | NULL       | NULL |
+--------------+------------+------+

mysql>

もちろん、私はすでにグーグルと検索のstackoverflowを持っています。

4

1 に答える 1

1
SELECT
    t.*
FROM 
    (SELECT 1) AS dummy
  LEFT JOIN
    (SELECT ... your select here) AS t
      ON TRUE ;

だから、質問に固執する:

SELECT
    t.*
FROM 
    (SELECT 1) AS dummy
LEFT JOIN
    ( SELECT
        "Le Café de la Mairie" as titre,
        "15 pl Mairie" as adresse1,
        id
      FROM ville
      WHERE sound=soundex('FERTE SOUS JOUARRE')
      AND cp='77261') AS t
ON TRUE;
于 2013-03-17T20:31:49.107 に答える