Hi, as soon as I add a JOIN clause in my SQL request (browse FORM), it stops working (no record is returned); if I remove the clause (and the relevant fields to be displayed) I get the expected rows.
How can I handle this clause?
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
A Browse form containing a JOIN
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
-
- Posts: 25
- Joined: Sat Apr 03, 2021 3:50 pm
Re: A Browse form containing a JOIN
My SQL is:
Result is as expected on phpMyAdmin
Code: Select all
SELECT consultations.date, patients.nom, patients.prenom, consultations.type, consultations.prix, consultations.type_reglement
FROM consultations JOIN patients ON consultations.id_patient = patients.id
WHERE consultations.date_encaissement IS NULL
ORDER BY consultations.date DESC
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
Re: A Browse form containing a JOIN
Make sure that the column names in the column Display are written exactly as in the SELECT statement.
If you press CTRL+SHIFT+I (Options Menu -> Form Info) you will see the generated SQL.
If you press CTRL+SHIFT+I (Options Menu -> Form Info) you will see the generated SQL.
You do not have the required permissions to view the files attached to this post.
-
- Posts: 25
- Joined: Sat Apr 03, 2021 3:50 pm
Re: A Browse form containing a JOIN
Both tables have 'id' as their primary key fields, and the generated SQL tries to select the ambiguous field 'id'.
Do I have to change the name of my column in the database and fix the change everywhere in NuBuilder, or can I still do it as it?
Do I have to change the name of my column in the database and fix the change everywhere in NuBuilder, or can I still do it as it?
-
- Posts: 25
- Joined: Sat Apr 03, 2021 3:50 pm
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
Re: A Browse form containing a JOIN
Could could try a SELECT ... FROM ... SELECT:
Code: Select all
SELECT date, nom, prenom, type, prix, type_reglement FROM (
SELECT consultations.id, consultations.date, patients.nom, patients.prenom, consultations.type, consultations.prix, consultations.type_reglement
FROM consultations JOIN patients ON consultations.id_patient = patients.id
WHERE consultations.date_encaissement IS NULL
) T
ORDER BY consultations.date DESC