How to use MySQL UNION in qa_db_query_sub function?

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

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:
Trump administration equity stakes pose risks to U.S. companies and markets
voice message by recording in question area
The new Bilt 2.0 cards are open for application. Here's how to decide which card is right for you
Here are the 5 big things we're watching in the stock market this week
Top Wall Street analysts like these stocks for long-term growth potential
Hims & Hers pulls copycat weight-loss pill after threats of legal action
Epstein files: UK PM Starmer's top aide McSweeney quits over Mandelson scandal
Elon Musk wants to be a trillionaire — here's how SpaceX may get him there
Federal judge orders Fulton County Georgia election case documents unsealed by Tuesday
Japan's Nikkei 225 skyrockets over 5% to hit record highs as Takaichi secures historic mandate