0

When I try to execute this SQL query, I get an error and I don't know how to correct it

select  * 
from    pg_specialites_annees   pgs  
where   pgs.NOM_FR like '%tets%' 
left join pg_specialites_parametres pgsp on pgsp.ID_SPECIALITE = pgs.ID_SPECIALITE; 

When I remove the LIKE it works, but I need a specific row.

Please help me, I don't know how to do it. I want to show some details for a specific row in table from another table.

2
  • SQL expects statements to be in the following order: SELECT, FROM, JOIN, ON, WHERE, GROUP BY, HAVING, ORDER BY which is not the same order as execution. Commented Dec 22, 2015 at 13:58
  • The complete and correct syntax for a select statement is documented in the manual of your DBMS. Commented Dec 22, 2015 at 14:33

2 Answers 2

1

Your LEFT JOIN needs to come before the WHERE:

Select      * 
From        pg_specialites_annees       pgs  
Left Join   pg_specialites_parametres   pgsp    on  pgsp.ID_SPECIALITE = pgs.ID_SPECIALITE
Where       pgs.NOM_FR Like '%tets%';
Sign up to request clarification or add additional context in comments.

Comments

1

Put your where clause after the join clause :

select * from pg_specialites_annees pgs  
        left join pg_specialites_parametres pgsp on pgsp.ID_SPECIALITE = pgs.ID_SPECIALITE;
        where  pgs.NOM_FR like '%tets%' 

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.