I have these tables in my database:
Contacts
-contact_id
-contact_name
File
-file_id
-file_code
-customer_id
-hauler_id
File_details
-file_id
-loadunload_id
-loadunload_date
-loadunload_time
LoadUnload
-loadunload_id
-loadunload_place
And these inputs as search fields on my webpage. Results are sent through Ajax, the whole system will run in an offline local network:
"File Code" (file.file_code)
"Customer Name" (contacts.contact_name)
"Hauler name" (contacts.contact_name)
"Load place" (loadunload.loadunload_place)
"Load date" (loadunload.loadunload_date)
"Unload place" (loadunload.loadunload_place)
"Unload date" (loadunload.loadunload_date)
Which should get me the following results on my screen:
File Code | Customer | Load place | Load time | Unload place | Unload time | Weight | Hauler
One filled in search field should show a result as wel as multiple filled in search fields. All I really need is my file.file_id. With that I can show everything else I need in my html table, but I don’t have a single clue how my SQL should look like. My guess is I need about a million joins in my sql?
I’ve attached a link with a screenshot, which may make things easier to understand. Screenshot link
Assuming that
File.customers_idis the foreign key forContacts.contact_id, thesqlshould be:This should return all entries. For filtering add a
WHEREclause:Hope this helps