将 MySQL IFNULL() 与 SELECT 查询一起使用时出错
Error when using MySQL IFNULL() with SELECT query
请检查下面的MySQL代码。
SELECT seller_job_invites.idseller_job_invites,
seller_job_invites.idjob,
seller_job_invites.iduser as seller_id,
seller_job_invites.idjob_status,
user.iduser AS buyer_id,
user.first_name AS buyer_first_name,
user.last_name as buyer_last_name,
user.profile_picture AS buyer_profile_picture,
job.idjob_subcategories,
job.posted_date,
job.start_date,
job.location_lat,
job.location_long,
(SELECT IFNULL((SELECT translations.word FROM translations WHERE translations.dtype="JOB_SUB_CATEGORY" AND translations.language_code="FR" AND translations.fkey=job.idjob_subcategories) AS subcategory_name,(SELECT translations.word FROM translations WHERE translations.dtype="JOB_SUB_CATEGORY" AND translations.language_code="EN" AND translations.fkey=job.idjob_subcategories) AS subcategory_name)),
job_status.name AS 'job_status'
FROM peresia.seller_job_invites
INNER JOIN job ON seller_job_invites.idjob = job.idjob
INNER JOIN user ON job.iduser = user.iduser
INNER JOIN job_status ON seller_job_invites.idjob_status = job_status.idjob_status
WHERE seller_job_invites.iduser=52 AND (job_status.name = 'SELLER_SCREENING' OR job_status.name ='SELLER_INVITED')
请注意我使用的子查询。我想做的是 return 这个词的法文翻译,如果它是 NULL 那么 return 这个英文词。
这给了我以下错误。
Error Code: 1583. Incorrect parameters in the call to native function 'ifnull'
我该如何解决这个问题?
您似乎在 IFNULL 调用中分配了别名。删除它们并在函数调用之外添加一个别名。
请检查下面的MySQL代码。
SELECT seller_job_invites.idseller_job_invites,
seller_job_invites.idjob,
seller_job_invites.iduser as seller_id,
seller_job_invites.idjob_status,
user.iduser AS buyer_id,
user.first_name AS buyer_first_name,
user.last_name as buyer_last_name,
user.profile_picture AS buyer_profile_picture,
job.idjob_subcategories,
job.posted_date,
job.start_date,
job.location_lat,
job.location_long,
(SELECT IFNULL((SELECT translations.word FROM translations WHERE translations.dtype="JOB_SUB_CATEGORY" AND translations.language_code="FR" AND translations.fkey=job.idjob_subcategories) AS subcategory_name,(SELECT translations.word FROM translations WHERE translations.dtype="JOB_SUB_CATEGORY" AND translations.language_code="EN" AND translations.fkey=job.idjob_subcategories) AS subcategory_name)),
job_status.name AS 'job_status'
FROM peresia.seller_job_invites
INNER JOIN job ON seller_job_invites.idjob = job.idjob
INNER JOIN user ON job.iduser = user.iduser
INNER JOIN job_status ON seller_job_invites.idjob_status = job_status.idjob_status
WHERE seller_job_invites.iduser=52 AND (job_status.name = 'SELLER_SCREENING' OR job_status.name ='SELLER_INVITED')
请注意我使用的子查询。我想做的是 return 这个词的法文翻译,如果它是 NULL 那么 return 这个英文词。
这给了我以下错误。
Error Code: 1583. Incorrect parameters in the call to native function 'ifnull'
我该如何解决这个问题?
您似乎在 IFNULL 调用中分配了别名。删除它们并在函数调用之外添加一个别名。