PostgreSQL打印结果来自查询空行

时间:2016-03-08 14:23:10

标签: postgresql

我写了这个查询,但结果是空的。如何打印没有空行的结果。我将附上结果的屏幕截图。

enter image description here

SELECT user_data.alternative_mail
FROM user_data
JOIN users_map
ON users_map.user_id = user_data.user_id
WHERE users_map.service_id = 1 AND 
    users_map.service_user_id = 0 AND
    user_data.alternative_mail NOT LIKE '%@abv.bg'

1 个答案:

答案 0 :(得分:1)

您可以检查电子邮件IS NOT NULL是否为空字符串:

SELECT user_data.alternative_mail
FROM user_data
JOIN users_map
  ON users_map.user_id = user_data.user_id
WHERE users_map.service_id = 1 
  AND users_map.service_user_id = 0 
  AND user_data.alternative_mail NOT LIKE '%@abv.bg'
  AND user_data.alternative_mail IS NOT NULL 
  AND user_data.alternative_mail <> '';