Note that there are some explanatory texts on larger screens.

plurals
  1. POFilter Left join sql
    primarykey
    data
    text
    <p>I have this sql query : </p> <pre><code>SELECT Customer.IDCustomer, Customer.Name, Sign.IdSign, Sign.Name, Sign.Delete FROM Customer LEFT JOIN Sign_Customer ON Sign_Customer.IDCustomer=Customer.IDCustomer AND ( SELECT CAST(CASE WHEN S_C.Delete=0 OR S_C.Delete is Null THEN 1 ELSE 0 END AS BIT ) FROM Sign AS S_C WHERE S_C.IdSign=Sign_Customer.IdSign)=1 LEFT JOIN Sign ON Sign.IdSign=Sign_Customer.IdSign ORDER BY Customer.Name </code></pre> <p>This query works fine, but I want to know if it exists another way to filter my first left join without use the SELECT CAST... condition. </p> <hr> <h2>Update</h2> <p>Sorry, I don't explain what I want in my result:</p> <ul> <li>All my customer without Sign </li> <li>All my customer whith enable Sign</li> </ul> <p>A Customer with disable Sign doesn't appear or appear like a "without Sign" if no enable Sign exist for it.</p> <p>Exemple: my customer table</p> <pre><code>IDCustomer | Name 1 | Customer 1 2 | Customer 2 3 | Customer 3 4 | Customer 4 </code></pre> <p>Sign_Customer:</p> <pre><code>IDCustomer | IdSign 1 | 1 3 | 2 3 | 3 3 | 5 4 | 4 </code></pre> <p>Sign</p> <pre><code>IdSign | Name | Delete 1 | Sign1 | 0 2 | Sign2 | 1 3 | Sign3 | 0 4 | Sign4 | 1 5 | Sign5 | 0 </code></pre> <p>Result</p> <pre><code>Customer.IDCustomer | Customer.Name | Sign.IdSign | Sign.Name | Sign.Delete 1 | Customer 1 | 1 | Sign1 | 0 2 | Customer 2 | null | null | null 3 | Customer 3 | 3 | Sign3 | 0 3 | Customer 3 | 5 | Sign5 | 0 4 | Customer 4 | null | null | null </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload