How do I merge the results of select * and select count(*).

  mysql, question

There is an existing organization table, column ID,PARENT_ID

I want to do two queries, the first query query all results

select ID,PID from SM_ORGANIZATION;
 Plus-plus-plus-plus
 | ID                                   | PID                                  |
 Plus-plus-plus-plus
 | 02d48356-01a4-4e94-931e-8ded0bd7f3e5 | NULL                                 |
 | 03bb50c0-33a2-11e5-fc3e-2fe7bed2d47f | NULL                                 |
 | 0bb3a2e5-ee6f-11e5-fd4f-1b751af35d55 | NULL                                 |
 | 1fd0edc1-da90-11e5-fce6-21c5a127d649 | 43def2ae-a881-11e5-fc3e-35dcca6e148c |
 | 2f5a44dd-54d0-11e5-fcd5-99ae2cb8560f | 43def2ae-a881-11e5-fc3e-35dcca6e148c |
 | 3b3c6659-dff3-40f3-b528-2f595ac1c36b | NULL                                 |
 | 43def2ae-a881-11e5-fc3e-35dcca6e148c | NULL                                 |
 | 75241a24-b0a1-4101-9c09-4dd9f5e84f50 | NULL                                 |
 | 8305a3da-fef3-11e6-e79e-767a95d254a2 | NULL                                 |
 | e8d71f93-cdc3-4bdd-aa0c-1bc661a419ec | NULL                                 |
 | fd026b14-ec9c-4f4f-9178-ad3b4ff1f21f | NULL                                 |
 Plus-plus-plus-plus

The second query is to query PID according to each result ID found in the first query as a condition to determine whether it is a parent node or not.

Select
 IF(IS_LEAF = 0, 0, 1) IS_LEAF
 From
 (SELECT
 COUNT(*) IS_LEAF
 FROM SM_ORGANIZATION
 WHERE PID ='43def2ae-a881-11e5-fc3e-35dcca6e148c'
 ) SM_ORGANIZATION;
 Plus-plus
 | IS_LEAF |
 Plus-plus
 |       1 |
 Plus-plus

Now I want to merge the two queries into one query statement. How should I write the three columns of ID, PID and IS_LEAF?

Plus-plus-plus-plus-plus
 | ID                | PID                |IS_LEAF           |
 Plus-plus-plus-plus-plus
SELECT s1.*,IF(s2.PID IS NULL,0,1)
 FROM SM_ORGANIZETION s1
 LEFT JOIN (
 SELECT PID
 FROM SM_ORGANIZETION
 GROUP BY PID) s2
 ON s1.ID=s2.PID;