How to use MySQL UNION in qa_db_query_sub function?

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

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:
AstraZeneca is listing in New York, as Big Pharma balances the huge U.S. market with China's tempting innovation
question2answer have everything accept one...
Housing affordability isn't just hurting buyers: More homeowners are falling behind on their mortgages
Disney beats Wall Street expectations propelled by theme parks and streaming
Erratic behavior in bitcoin, silver and memory stocks threatens to unnerve bull market
Goldman upgrades this Tencent-backed digital brokerage firm, flags crypto trading as growth driver
How to show question title before question meta in question list like SnowFlat theme. (Mayropro theme)
Washington Post begins widespread layoffs, sharply shrinking storied newspaper's reach
China ramps up threats over Panama Canal ruling that handed Trump a major victory
A surprising share of homeowners have high mortgage rates. Here's the breakdown