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>

当然,我已经 google & search 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 回答