# |
Sep 4th 2019, 17:38 |
neon1024 |
I guess an example might be searching for a person, you may union Customers and Users |
# |
Sep 4th 2019, 17:38 |
neon1024 |
At least, that’s my understanding! |
# |
Sep 4th 2019, 17:37 |
ricksaccous |
i seee |
# |
Sep 4th 2019, 17:37 |
neon1024 |
That would work if there is an association, often a union might not contain data from associated tables. Such as in a global search, but for that usually you’d use something like Elasticsearch |
# |
Sep 4th 2019, 17:36 |
ricksaccous |
on whatever you need to be unique |
# |
Sep 4th 2019, 17:36 |
ricksaccous |
you could just do innerjoinwith can't you and then use the proper distinct/groupBy |
# |
Sep 4th 2019, 17:36 |
neon1024 |
I’ve never found a need to use it, ever, which is why I was curious that @lilhermit would want to use it |
# |
Sep 4th 2019, 17:36 |
ricksaccous |
oh |
# |
Sep 4th 2019, 17:35 |
neon1024 |
Rather like a cross join would |
# |
Sep 4th 2019, 17:35 |
neon1024 |
@ricksaccous Union will join the results of two queries into a single resultset |
# |
Sep 4th 2019, 17:13 |
ricksaccous |
why don't you just innerjoinwith and distinct, what does union even do, man i'm so bad at sql |
# |
Sep 4th 2019, 16:39 |
jotpe |
@alexdd55976 I don't know if this helps you, but for my purpose it is working : https://gist.github.com/julianpollmann/bd2dc4c8092d3d416f5a7bdc8ea68342 |
# |
Sep 4th 2019, 16:20 |
lilhermit |
I need to wrap that `$query` but for the life of me I can't get it to work |
# |
Sep 4th 2019, 16:20 |
lilhermit |
https://pastebin.com/4SNWVG8V |
# |
Sep 4th 2019, 16:16 |
lilhermit |
lol |
# |
Sep 4th 2019, 16:12 |
neon1024 |
I certainly wouldn’t have appreciated a large flood of code in a PM |
# |
Sep 4th 2019, 16:12 |
neon1024 |
You could share your code using a Gist or Pastebin and share the link |
# |
Sep 4th 2019, 16:11 |
lilhermit |
I didn't want to flood the channel with my complex explanation and code. Was going to post my solution after |
# |
Sep 4th 2019, 16:09 |
neon1024 |
Limiting your support to one person when you have 3,235 other people who might help you seems unwise |
# |
Sep 4th 2019, 16:09 |
neon1024 |
:man-shrugging: |
# |
Sep 4th 2019, 16:07 |
lilhermit |
@neon1024 I've dm'ed you |
# |
Sep 4th 2019, 16:04 |
neon1024 |
Or make a branch in Git or similar to save time reverting |
# |
Sep 4th 2019, 16:04 |
neon1024 |
Well perhaps just write a new method in the controller and see what it looks like |
# |
Sep 4th 2019, 16:03 |
slackebot |
Action: lilhermit tries to adapt |
# |
Sep 4th 2019, 15:55 |
neon1024 |
Does this kind of thing not work then? |
# |
Sep 4th 2019, 15:55 |
slackebot |
<neon1024> |
# |
Sep 4th 2019, 15:53 |
lilhermit |
OK I'll take a look |
# |
Sep 4th 2019, 15:53 |
neon1024 |
https://book.cakephp.org/3.0/en/orm/query-builder.html#unions |
# |
Sep 4th 2019, 15:53 |
lilhermit |
I'm trying to do that |
# |
Sep 4th 2019, 15:52 |
neon1024 |
There is a whole bit in the book about sub-queries |
# |
Sep 4th 2019, 15:52 |
neon1024 |
So you’re doing `SELECT * FROM (SELECT x,y FROM..` query? |
# |
Sep 4th 2019, 15:45 |
neon1024 |
No idea then, I’m afraid. |
# |
Sep 4th 2019, 15:45 |
neon1024 |
I would question the need for a Union, but I’m sure there is a reason |
# |
Sep 4th 2019, 15:44 |
lilhermit |
yes I have a union and my understanding is I need to wrap it so that paginator LIMITs are not added to the first query |
# |
Sep 4th 2019, 15:43 |
lilhermit |
yes `->select('*')` adds table name and `as` |
# |
Sep 4th 2019, 15:42 |
neon1024 |
As long as you understand the implications of a `SELECT * FROM` query |
# |
Sep 4th 2019, 15:41 |
neon1024 |
Did you try `->select('*')` ? |
# |
Sep 4th 2019, 15:41 |
lilhermit |
I'm wrapping a query inside a `from` so paginator can will work with a union |
# |
Sep 4th 2019, 15:40 |
lilhermit |
Hi, anyone know if to stop QueryBuilder `select` method from add an alias. I want just `select * from ` rather than `select TableName.* as TableName__*` |
# |
Sep 4th 2019, 15:05 |
neon1024 |
:thumbsup: |
# |
Sep 4th 2019, 15:04 |
daniel.upshaw |
I think it was, thanks so much @neon1024 |