Created
September 5, 2012 05:47
-
-
Save oojacoboo/3631211 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @settingName = "feeMID", @companyId = 1; | |
SELECT COALESCE(company_setting.value, default_setting.value) AS value | |
FROM default_setting | |
LEFT JOIN company_setting | |
ON company_setting.default_setting_id | |
WHERE default_setting.name = @settingName | |
AND company_setting.company_id = @companyId |
SET @SettingName = "test", @companyid = 1;
SELECT COALESCE(
(
SELECT cs.value
FROM company_setting cs
LEFT JOIN default_setting ds
ON cs.default_setting_id = ds.id
WHERE cs.company_id = @companyid
AND ds.name = @SettingName
),
(
SELECT ds.value
FROM default_setting ds
WHERE ds.name = @SettingName
)
) AS value
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SET @SettingName = "feeMID", @companyid = 1;
SELECT COALESCE(
(
SELECT cs.value
FROM default_setting ds
INNER JOIN company_setting cs
ON cs.default_setting_id
WHERE cs.company_id = @companyid
AND ds.name = @SettingName
),
(
SELECT ds.value
FROM default_setting ds
INNER JOIN company_setting cs
ON cs.default_setting_id
WHERE cs.company_id = @companyid
AND ds.name = @SettingName
)
) AS value;