4D has supported cross table queries since the introduction of the SQL engine in V11.
Given a table of sales reps ("Managers") and a Territories table (not my table name convention) that have a many to many table ManagerToTerritory, the following code will find the territories for a given manager: QUERY([Territories]; [Managers]ID=$managerID_T) You can also use Query by formula. That command is very flexible and very fast. Paraphrasing Thomas Maul on the Forum some years ago, you should be using QbF if your search has two or more clauses. The syntax is very SQL-like: QUERY BY FORMULA([Proposals]; ([Proposals]ID=[Line_Items]Proposal_ID) & (([Line_Items]Product_Code=$productCode_T))) QUERY BY FORMULA([Proposals]; ([Documents]Tablenumber=22) & ([Documents]Record_ID=[Proposals]ID)) Add code like this to see how 4D is handling the query: DESCRIBE QUERY EXECUTION(True) *QRY_QueryPlanToClipboard* DESCRIBE QUERY EXECUTION(False) The code for *QRY_QueryPlanToClipboard* //---------------------------------------------------- //User name (OS): dvonroeder //Date and time: 08/21/14, 17:01:30 //---------------------------------------------------- //Method: QRY_QueryPlanToClipboard // C_TEXT($plan_T; $path_T) $plan_T:="Query Plan"+Char(13)+Get last query plan(Description in text format) $path_T:="Query Path"+Char(13)+Get last query path(Description in text format) SET TEXT TO PASTEBOARD($plan_T+Char(13)+Char(13)+$path_T) -- Douglas von Roeder 949-910-4084 On Sat, Oct 30, 2021 at 12:20 AM Jörg Knebel via 4D_Tech < 4d_tech@lists.4d.com> wrote: > > > > On 29 /10 /2021, at 10:24, Stephane Potvin via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > > > > Main table is client information, linked table for services provided. > > Beside the super duper modern cool way to get a result what about the > solid old way: > > $DateServiced:=Add to date(current date(*);-1;0;0) // or value entered by > a user > > QUERY ([Services]LastServicedDate<=$DateServiced) > RELATE ONE SELECTION([Services];[Clients]) > > Your description about the menus is a knew one to me - sorry. > > HTH > > Cheers > Jörg > ********************************************************************** > 4D Internet Users Group (4D iNUG) > New Forum: https://discuss.4D.com > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ********************************************************************** ********************************************************************** 4D Internet Users Group (4D iNUG) New Forum: https://discuss.4D.com Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************