我已经用case编写了一个查询,但是我遇到了()问题。
select SM.subscriber_name as name ,
SM.accountType as accountType,
SM.middlename as middleName,
SM.lastname as lastName,
SM.title as title,
SM.email as email,
SM.company as company,
SM.email1 as aEmail,
,
SM.zipcode as zipcode,
SM.phone_no as phoneNumber,
SM.landlinenumber as landlineNumber,
SM.login_id as loginId,
SD.subscriberType as subscriptionType,
SD.product_id as productType,
case SM.state when 'null' then '' as state else STDD.state_name as state end,
case SM.city when 'null' then '' as city else CDD.city_name as city end,
case SM.country when 'null' then '' as country else CD.country_name as country end,
SD.fulldownloadaccess as fullDownloadAccess,
SD.emailid_limit as emailLimit,
SD.acessTime as planTime
from subscriber_master SM ,
subsciber_details SD,
city_details CDD,
state_details STDD,
country_details CD
where SM.subscriber_id=16704 and
SM.subscriber_id=SD.subscriber_id and
SM.country = CD.country_id and
SM.state = STDD.state_id and
SM.city = CDD.city_id;
请帮我把支架放在哪里
3条答案
按热度按时间koaltpgm1#
我想说的是,您希望将null显示为空值,因此,您需要重建查询,如下所示:
改写为:
所有的“null”也是一样的。此外,应在案件结束后写上as
复习:刚刚意识到下面的句子应该是相同的,但要简洁得多,更容易阅读:
iqjalb3h2#
你可以改变主意
case
语句,它将检查null
和空白值你应该使用
join
用于在select语句中提供不同表之间的where条件。或者,您可以使用下面修改过的查询vuv7lop33#
你的查询有几个问题。首先是你的
CASE
如果表达式编写不正确,则表达式必须完整才能执行任何操作AS
例如,应写为
另外,如果您正在检查
NULL
值,而不是字符串值'null'
,您需要编写CASE
表达式为:你还有一个额外的
,
(双方SM.email1 as aEmail,
以及SM.zipcode as zipcode,
).然而,这些问题都不会给你的消息在你的标题,有一些代码你没有给我们看?