Note that there are some explanatory texts on larger screens.

plurals
  1. POselect statement with where condition (select all or some)
    primarykey
    data
    text
    <p>I have to following tables:</p> <p>images:</p> <pre><code>imageID userId Translated theImage -------------------------------------------- 1 2 1 image1 2 3 0 image2 3 3 0 image3 4 3 0 image4 5 3 1 image5 </code></pre> <p>and translationChains:</p> <pre><code>imageID sourceLang targetLang ------------------------------------ 1 2 3 2 4 1 3 5 1 4 4 2 5 1 4 </code></pre> <p>now I have two options: I want either to choose all the images the wasn't translated for a specific user in any language or to choose all the images for this user that wasn't translated in a specific language.</p> <p>I have the following query for the first option:</p> <pre><code>"Select images.imageid, images.theimage, images.translationRating From images where images.userID=? And images.translated =0" </code></pre> <p>and for the second option I have:</p> <pre><code>"Select images.imageid, images.theimage, images.translationRating From images, translationchains where images.userID=? And images.translated =0 and translationchains.imageId = images.imageid and translationchains.targetLang = ? " </code></pre> <p>for example if i'll use the first query with user 3 I want the result to be:</p> <pre><code>2 3 0 image2 3 3 0 image3 4 3 0 image4 </code></pre> <p>and for the second query with user 3 and targerLang = 1 I want the result to be:</p> <pre><code> 2 3 0 image2 3 3 0 image3 </code></pre> <p>I want to combine this two queries into one query that will work in all cases (according to the parameters that i'll send)</p> <p>how can I do it?</p> <p>I was trying to send as the second parameter (translationchains.targetLang = ?) the string " " (empty string) so it will ignore this condition but it didn't work</p>
    singulars
    1. This table or related slice is empty.
    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.
    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