How to use MySQL UNION in qa_db_query_sub function?

Post date: 2020-08-11 05:24:21
Views: 182

Although it seems that qa_db_query_sub function will be deprecated in Q2A 1.9.0, but still I would like to ask how to use MySQL UNION in qa_db_query_sub function?

This simple SELECT function works well

SELECT postid FROM  `qa_posts`  WHERE `type`="Q"  ORDER  BY created DESC  LIMIT  1

qa_db_read_all_assoc(qa_db_query_sub('SELECT postid FROM  `qa_posts`  WHERE `type`="Q"  ORDER  BY created DESC  LIMIT  1'));

But this compound function doesn't work:

SELECT postid FROM  `qa_posts`  WHERE `type`="Q"  ORDER  BY created DESC  LIMIT  1 UNION ALL SELECT postid FROM  `another_posts`  WHERE `type`="Q"  ORDER  BY created DESC  LIMIT  1

Or even this doesn't work either

(SELECT postid FROM  `qa_posts`  WHERE `type`="Q"  ORDER  BY created DESC  LIMIT  1) UNION ALL (SELECT postid FROM  `another_posts`  WHERE `type`="Q"  ORDER  BY created DESC  LIMIT  1)

qa_posts and another_posts have the same structure in this example.

Please click Here to read the full story.
 
Other Top and Latest Questions:
Apple's elevation of silicon head Johny Srouji signals sprint to build in-house chips for all devices
Jim Cramer says these stocks show why you need to trade on fundamentals, not fear
Worried about rising gas prices? These 5 credit cards save on transit, rideshare and more
Marvell stands to gain from boosted Amazon-Anthropic partnership
How to donate medicine?
Movie: The Blue Caftan
These stocks may rip if the Iran conflict is resolved, UBS says
European stocks set to open lower as Trump refuses to lift Strait of Hormuz blockade
CEO with over $3 trillion under management tells Gen-Z to think past ‘hobby investing’
Japan's Nikkei 225 rises to record high as Trump extends Iran ceasefire