0

I want to display some products filtered by text or by category using a combobox or the two combined.

example

The problem is I'm stuck on the prepared statement SQL query:

String sqlMaj = "SELECT * FROM product as prod"
                    + "INNER JOIN utilisateurs as ut ON prod.no_utilisateur = ut.no_utilisateur "
                    + "INNER JOIN retraits as ret ON ret.no_article = prod.no_article "
                    + "INNER JOIN categories as cat ON cat.no_categorie = prod.no_categorie "
                    + "WHERE prod.name LIKE ? AND cat.name= ? ";

Here is my combo box

<select name="category" id="inputState" class="form-control">
        <option value="1=1" selected>Toutes</option>
        <c:forEach items="${listCategories}" var="category">
            <option value="${category}">${categorie}</option>   
        </c:forEach>
      </select>

I'm stuck there because when the user want to search with the text bar in ALL the categories, I don't know what to put in cat.name = ?

Can you help me by giving me some example or explain to me what I'm doing wrong?

0 Answers0