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!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
A Browse form containing a JOIN
-
- nuBuilder Team
- Posts: 4307
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 447 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: 4307
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 447 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: 4307
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 447 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