SQLQueryMaster.Datasource := Master_table;
SQLQueryMaster.SQL.text := 'Select * from Column_Name where TABLE=:Column_Name';
SQLQueryMaster.SQL.text := 'Select * from Column_Name where TABLE=:DBLookupComboBox.Keyfield';
But to no avail.As there's no direct connection between the vehicle and customer databases I can't use a JOIN statement either.But there is a direct connection between vehicle and hire, and hire and customer. So you can use multiple left joins.
Sqlquery4.sql.text := 'Select * from fares where departure = :DEPPOINT and destination = :ARRPOINT';
Sqlquery4.params.parambyname('DEPPOINT').Asstring := Edit3.text;
Sqlquery4.params.parambyname('ARRPOINT').Asstring := Edit4.text;
There has to be a way for me to select data from table C where it matches table A and table B, I just can't figure out how.As of now you only explained one table. Fares (probably C)
There is another DBLookupComboBox beneath it, which selects all locations encountered on that route.How is this possible when there's no relation to table ROUTE?
(let's just say there are multiple routes all running into a City, I'd have to duplicate the fares for each and every route between two points).But you still haven't explained yet how these tables connect to each other. You say you have a route table but I only see a name in that. Not a destination or departure.
Thanks all.by what I gave two different strategies please be specific.
Eljo, I'm really sorry but I don't understand what you mean by that. I'm familiar with joining tables in SQL statements as I used that in MS Access.
If I understand rightly, you mean leave the DBLookupComboBox 'as is' and then the TBGrid underneath it uses a SQL string joining the route table and fares table below it?No, the opposite. Joining the route table with dDBLookupComboBox above to create a single dataset with all the keys you need for the fares datasets.
That would work if there were only one or two routes, but if there were several (let's just say there are multiple routes all running into a City, I'd have to duplicate the fares for each and every route between two points).I have no idea what you are objecting about, to me it looks like that longer routes should be more expensive than shorter routes on the same finish then again I haven't touched that subject at all.
I can perform a search based on "select any record where column X equals the contents of editbox1" (written in English!) and I dare say I could apply two criteria by using two editboxes... yet I can't use something similar to query based on the visible string in a lookup combo box- or at least I haven't found it yet.em what that has to do with anything? are you telling me that there is a link between the route name and some other field in the fares table?
Can anyone recommend any good books on the subject? Something as simple as this should be easier to implement and I cannot keep bothering you good people.Which subject? relational databases, sql language, data access library of fpc (SQLDB) something I missed? maybe it would be easier to create a small demo application with a demo database to show how your form works at the moment and a small text demonstrating what you need to remove or add, in which control of your form. I guess solving the specific case will be more beneficial to you at the moment instead of the generic guides to general directions of development.
If this the three tables you talk about there's no relation at all.Correct.QuoteThere is another DBLookupComboBox beneath it, which selects all locations encountered on that route.How is this possible when there's no relation to table ROUTE?