How to use MySQL UNION in qa_db_query_sub function?

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

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:
Donald Trump Jr. exits advisory role at Kalshi prediction market
Who will replace Jensen Huang? Here's our early thoughts on the search for Nvidia's next CEO
NHL’s next media deal will test the league’s strength
This cybersecurity stock is down nearly 20% over the past month. KeyBanc says it's a buy
In a policy switch, the Fed says its October 2027 meeting will not see a vote on interest rates
Slice-of-life blogs from the Beforetimes?
sports podcasts (especially North American sports: MLB, NHL, NBA)
U.S. seizes $1.2 billion in cryptocurrency stolen from Binance
CNBC's Official NHL Team Valuations 2026: How the 32 franchises stack up
Why Nvidia stock drop isn't a big deal for many ETF, mutual fund investors