UNION SELECT with db sql-mapper

34 views
Skip to first unread message

Christophe Rolland

unread,
Jun 10, 2022, 5:27:39 AM6/10/22
to Fat-Free Framework
Hello,

I'm searching a way to use UNION on DB\SQL\Mapper with a request like this :
SELECT * FROM table1 where param_1 = :var1 and param_2 = :var2
UNION
SELECT * FROM table1 where param_1 = :var2 and param_2 = :var1

Any idea to do this ?

Thanks for your reply,
Best.

C.






Paul Herring

unread,
Jun 10, 2022, 6:04:19 AM6/10/22
to Christophe Rolland via Fat-Free Framework
Well that particular example could be written as a single non-union query:
 
$query = [ ' (param_1 = ? and param_2 = ?) or (param_1 = ? and param_2 = ?)', var1, var2, var2, var1 ];
$table->find($query);

But I suspect that what you're after is more complicated?

If so, I'm unsure how to use UNION, other than actually writing it out longhand and using $table->exec().


--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to the Google Groups "Fat-Free Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to f3-framework...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/13978ff9-10e0-4e56-a506-8e512d29b221n%40googlegroups.com.


--
PJH

Christophe Rolland

unread,
Jun 10, 2022, 6:19:11 AM6/10/22
to Fat-Free Framework on behalf of PJH
Hello PJH,

Thanks for your point of view on this question.
The results will be the same on this request.

Best regards,

C.


You received this message because you are subscribed to a topic in the Google Groups "Fat-Free Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/f3-framework/CMOGGho2_Lc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to f3-framework...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/CAEWO_9QxQZK3TQQ7Yarx347%2BVTgY593bxLh5ac8e2y-HUpXeyw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages