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.

browsesql browse form issue

Questions related to using nuBuilder Forte.
Post Reply
Timo
Posts: 221
Joined: Thu Mar 15, 2018 9:26 pm
Has thanked: 1 time

browsesql browse form issue

Unread post by Timo »

I have two tables that look like this:

Table Notes:

Code: Select all

╔══════════╦═════════════════╗
║ nid      ║    forDepts     ║
╠══════════╬═════════════════╣
║ 1        ║ 1,2,4           ║
║ 2        ║ 4,5             ║
╚══════════╩═════════════════╝
Table Positions:

Code: Select all

╔══════════╦═════════════════╗
║ id       ║    name         ║
╠══════════╬═════════════════╣
║ 1        ║ Executive       ║
║ 2        ║ Corp Admin      ║
║ 3        ║ Sales           ║
║ 4        ║ Art             ║
║ 5        ║ Marketing       ║
╚══════════╩═════════════════╝
This is the sql for the Browse Form:

Code: Select all

SELECT  a.nid, GROUP_CONCAT(b.name ORDER BY b.id) DepartmentName
FROM    Notes a
INNER JOIN Positions b
ON FIND_IN_SET(b.id, a.forDepts) > 0
GROUP   BY a.nid
The output will look like this:

Code: Select all

╠══════════╬════════════════════════════╣
║ 1        ║ Executive, Corp Admin, Art ║
║ 2        ║ Art, Marketing             ║
╚══════════╩════════════════════════════╝
Issue: The browse form returns no rows.

nuCurrentProperties().browse_sql shows a completly messed up sql. How to make this work?

Code: Select all

SELECT a.nid, a.field1, a.field2 -- and all other fields (a.*)
FROM Notes a
INNER JOIN Positions b ON FIND_IN_SET(b.id, a.forDepts) > 0
GROUP BY a.nid
WHERE 1
ORDER BY b.id) DepartmentName
FROM Notes a
INNER JOIN Positions b ON FIND_IN_SET(b.id, a.forDepts) > 0
GROUP BY a.nid
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: browsesql browse form issue

Unread post by admin »

Timo,

What do you mean by this?
nuCurrentProperties().browse_sql shows a completly messed up sql
Steven
Timo
Posts: 221
Joined: Thu Mar 15, 2018 9:26 pm
Has thanked: 1 time

Re: browsesql browse form issue

Unread post by Timo »

admin wrote:
nuCurrentProperties().browse_sql shows a completly messed up sql
Please compare the two sql statements I posted. The latter is the one that got "mixed up".
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: browsesql browse form issue

Unread post by admin »

Timo,

nuBuilder has a fairly simple SQL parser.

If you want to use a complex statement like your's you might find the best way is to create a VIEW and then refer to that.

Steven
Timo
Posts: 221
Joined: Thu Mar 15, 2018 9:26 pm
Has thanked: 1 time

Re: browsesql browse form issue

Unread post by Timo »

Got it. I could work it out with a temporary table.
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: browsesql browse form issue

Unread post by admin »

Timo,

Yes, that's another good alternative.

Steven
Post Reply