php - SQL multiple join with empty results -


I am trying to create a SQL query for the search request on the table "Projects". Search is also related to other tables that belong to project tables.

I tried:

  SELECT projects Join documents in documents left on projects. = Projects.Id Include sub-documents on the left-hand documents. Include subdocuments_tags on subdocument except the .id = subdocuments.documentID .id = subdocuments_tags.subdocumentID subdocuments_tags.tagID = tags.id where tags (eg projects.name "% Test%" or projects like "% Test%" or "% Test%", or projects.defaultTags "% Test%", or "% Test%" or sub-documents like "clients", like projects. Name "% Test%" or document description "% Test%" or subdocument. Such as "% Test%" or tag. Such as name "% test%") and (Projects.hidden = 0 or projects.ownerID = 2 or projects_users.userID = 2) by Group BY Projects.id order projects. Upddetime DESC;   

The issue is that if there are no documents in the projects and the result is always empty without the WHERE clause.

@MatBailie

For more discussion ... < Pre> i table table if table is present in the table; Create table intent (not original primary key for INT); INSERT ints value (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); Create table table_a (INT no tap, x char (1) faucet, primary key (I, x)); Table 1 A, '1', '1', '1', '1', '1', '1', (1, 'E'), (2, 'A'), (2, 'B '), (2,' c '), (3,' a '), (3,' b '), (4,' a '); Select * from ints; + --- - | I + --- - | 0 | | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | Table_A from + --- + SELECT * + --- --- --- + | I X | + --- --- --- + | 1 | One | | 1 | B | 1 | C. | 1 | D | | 1 | E | 2 | One | | 2 | B | 2 | C. | 3 | One | | 3 | B | 4 | One | + --- --- + + + SELECT m. * Exiting the mile from * on the table_a NNI = NI = MI Where NX N ('C', 'D'); + --- - | I + --- - | 1 | | 1 | | 2 | + --- + SELECT m. * To INT I JOIN table_a n ON n.i = m.i WHERE n.x IN ('c', 'd'); + --- - | I + --- - | 1 | | 1 | | 2 | + --- +



Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -