How to use MySQL UNION in qa_db_query_sub function?

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

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:
Republicans push Obamacare tax credit alternatives as enrollment deadline looms
Alibaba shares rise as AI drives 34% cloud sales jump
Most retirees don't tell adult children about their inheritance, research shows. What advisors recommend sharing, when
We're buying more shares of a company that can deliver growth in a tough economy
Private payroll losses accelerated in the past four weeks, ADP reports
Nvidia stock falls 4% on report Meta will use Google AI chips
Michael Burry's next 'Big Short': An inside look at his analysis showing AI is a bubble
TSMC stock falls as it sues former exec alleging he took trade secrets to Intel
Sellers are taking their homes off the market at the fastest pace in nearly a decade
Consumer confidence hits lowest point since April as job worries grow