How to use MySQL UNION in qa_db_query_sub function?

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

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:
Tehran won’t surrender to the U.S., Iranian President Pezeshkian says, as India's Modi urges dialogue and peace
Prediction markets are becoming more professionalized, but also harder to beat
A Fed hike next week seems certain after the latest inflation data. Here's what's ahead
Iran and UAE back joint BRICS statement urging restraint in war
Movie: Lethal Weapon 3
Book: The Dream Hotel
Anthropic walks tightrope to Nasdaq, pushing for a slowdown while pursuing $2 trillion valuation
Trump says U.S. may keep Iranian oil 'like Venezuela' as Gulf-Iran Hormuz talks stall
I Customized KingMedia & Q2A – My AlGhorba.com Project + Free Help for Q2A Users
The 10-year Treasury is closing in on 5%. How it gets there matters more