How to use MySQL UNION in qa_db_query_sub function?

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

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:
Stocks like Nvidia have accelerating 'momentum,' Goldman Sachs says
Trump says China and Taiwan should 'both cool it'
What you need to know about Nvidia competitor Cerebras after wild IPO
Berkshire Hathaway returns to airlines with $2.6 billion stake in Delta Air Lines
What is this week's meal prep? Please share a recipe
Movie: Mortal Kombat II
The Boys: The Frenchman, the Female, and the Man Called Mother's Milk
For better or worse, investors are living through Trump’s stock market. Here's why
Cisco is the most overbought stock in the S&P 500. Here are the others.
UAE says its decision to leave OPEC was a strategic economic move, not a political one