-3

hi please check with me this sql query

SELECT 
    CAISSE.*
    ,IIf(USERS.USR_NOM_L IS NULL,CAISSE.USR_L, USERS.USR_NOM_L + ' ' + USERS.USR_PREN_L) AS CLIENT_L
    ,IIf(SOCIETE.SOC_ID = 0 ,CAISSE.SOC_L,SOCIETE.REF_L) AS SOC_REF_L 
FROM 
    (   CAISSE 
        LEFT JOIN USERS ON CAISSE.USR_ID = USERS.USR_ID
    ) 
    LEFT JOIN SOCIETE ON CAISSE.SOC_ID = SOCIETE.SOC_ID  
WHERE 
    1=1 ;

I need to add "and where SOCIETE.SITE='SiteName'" but this did not work because I didn't already selected SOCIETE table in the FROM clause. How can i do this?

9
  • do you have an error message, or what is the exact problem? Aug 12, 2014 at 9:26
  • 1
    @Strawberry It's a function used in SQL Server. Most likely the question is tagged wrong. Salah, what DBMS are you using?
    – fancyPants
    Aug 12, 2014 at 9:29
  • I'm using microsoft access Aug 12, 2014 at 9:35
  • the problem is when i add the condition in my left join i have "Expression join non supported" Aug 12, 2014 at 9:37
  • 1
    When you have more than 1 join you need parentheses for each respective join. stackoverflow.com/questions/7854969/sql-multiple-join-statement .. And I don't understand WHERE 1=1? Is that serving a purpose?
    – Mark C.
    Aug 12, 2014 at 12:26

1 Answer 1

0

well i found a solution for my problem thanks every body

SELECT * FROM (SELECT CAISSE.*,IIf(USERS.USR_NOM_L IS NULL,CAISSE.USR_L,

USERS.USR_NOM_L + ' '     + USERS.USR_PREN_L) AS CLIENT_L,

IIf(SOCIETE.SOC_ID = 0 ,CAISSE.SOC_L,SOCIETE.REF_L) AS SOC_REF_L,SOCIETE.SITE


FROM (CAISSE LEFT JOIN USERS ON CAISSE.USR_ID = USERS.USR_ID) 

LEFT JOIN SOCIETE ON CAISSE.SOC_ID = SOCIETE.SOC_ID)


WHERE SOCIETE.SITE='SiteName';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.