Note that there are some explanatory texts on larger screens.

plurals
  1. PO$query returns results but not the ones i want - having count?
    primarykey
    data
    text
    <p>I'll start again,</p> <p>Lets say My data is:</p> <p><strong>Table element</strong> (id,name,....)</p> <hr> <p>1, name element 1, ....</p> <p>2, name element 2, ....</p> <p>3, name element 3, ....</p> <p><strong>Table tags</strong> (id,name,id_element, ....)</p> <hr> <p>1, happy , 1</p> <p>2, result, 1</p> <p>3, very , 1</p> <p>4, element, 2</p> <p>5, another, 3</p> <p>6, element, 1</p> <p>7, happy, 2</p> <p><strong>So if search is '<em>very, happy,element,result</em>': Results i would like</strong></p> <hr> <p>1) element with id = 2 because it has all tags</p> <p>2) element with id = 1 because it has the tag 'element' and the tag 'happy' (only 2 less taggs)</p> <p>3) .... (only 3 less taggs)</p> <p><strong>So if search is '<em>happy,element</em>': Results i would like</strong></p> <hr> <p>1) element with id = 1 because it has all tags (and no more)</p> <p>2) element with id = 2 because it has the tag 'element' and the tag 'happy' (and two more tags)</p> <p>3) .... and 3 more tags</p> <hr> <p>This is an echo to my query: (it doesn't fit al requirements i wrote, but its first test to find with matched tags)</p> <pre><code>SELECT element.id as id_deseada,tagg.* FROM element,tagg WHERE tagg.id_element = element.id AND tagg.nombre IN ('happy','tagg','result') GROUP BY tagg.id_element ORDER BY element.votos </code></pre> <p>This returns 10 duplicated elements... :S and doen't even have all taggs (and on database there are taggs with 'happy' results)</p> <hr> <p>if it helps, thats how i get the elements of a tag (by name and with only one tagg)</p> <pre><code>$query = "SELECT element.id FROM element,tagg WHERE tagg.nombre = '$nombre_tagg' AND tagg.id_element = element.id AND lan = '$lan' GROUP BY tagg.id_element"; </code></pre> <hr> <p>I hope it's a bit easier to understand now, excuse my english.. :)</p> <p>------- EDIT ----------</p> <p>I Got this query working, goted from: <a href="http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html" rel="nofollow">http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html</a> (second example is my estructure)</p> <pre><code> SELECT b.* FROM scBookmarks b, scCategories c WHERE c.bId = b.bId AND (c.category IN ('bookmark', 'webservice', 'semweb')) GROUP BY b.bId HAVING COUNT( b.bId )=3 </code></pre> <p>imagine bookmark is element and category is tag (for my example)</p> <p>It works great, it returns all elements with ALL tags, BUT it return aswell the articles with extra tags,</p> <p><strong>for that query a possible ressult would be:</strong></p> <p><em>Element 6 with tags (bookmark, webserbice, semweb, extratag)</em> </p> <p>and i want this extra tag (actually any other extra tags), is something to do with HAVING COUNT ?</p> <p>I know</p> <p>Thanks a lot for you possible aportation!</p>
    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