How to use MySQL UNION in qa_db_query_sub function?

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

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:
Fanatics to launch sports media and entertainment studio
Pentagon to invest $1 billion in L3Harris rocket motor business, shares surge
Does it really matter who ends up owning Warner Bros.? Media exec Tom Rogers breaks it down
Buy this social media stock with lots of upside thanks to AI, says Evercore ISI
More drivers have $1,000-plus car loan payments. Here's what buyers can expect in 2026
Boeing secures tentative labor deal with former Spirit AeroSystems workers
Cloudflare acquires AI data marketplace Human Native
Japan's Mitsubishi to acquire shale gas assets in U.S. for $7.5 billion
Venezuela oil fetching 30% higher price, U.S. energy chief says, after first sale worth $500 million
Russia says it's monitoring Trump's 'extraordinary' push to take over Greenland