Skip to main content
added 16 characters in body
Source Link
xurshid29
  • 2.5k
  • 15
  • 13

I don't know this will help, but you can try:

$subquery1 = db_select('tab1','t1');
$subquery1->fields('t1',array('id','fname');
$subquery1->condition('t1.fname', 'Frank')

$subquery2 = db_select('tab2','t2');
$subquery2->fields('t2',array('id','fname');
$subquery1->condition('t2.lname', 'Sinatra')
$subquery2          ->orderBy('t2.fname','DESC');

$query = Database::getConnection()
  ->select($subquery1->union($subquery2, 'UNION ALL');
)
$result = $subquery1->execute>fields(NULL, array('id','fname');
...)

I don't know this will help, but you can try:

$subquery1 = db_select('tab1','t1');
$subquery1->fields('t1',array('id','fname');
$subquery1->condition('t1.fname', 'Frank')

$subquery2 = db_select('tab2','t2');
$subquery2->fields('t2',array('id','fname');
$subquery1->condition('t2.lname', 'Sinatra')
$subquery2->orderBy('t2.fname','DESC');

$subquery1->union($subquery2, 'UNION ALL');

$result = $subquery1->execute();
...

I don't know this will help, but you can try:

$subquery1 = db_select('tab1','t1');
$subquery1->fields('t1',array('id','fname');
$subquery1->condition('t1.fname', 'Frank')

$subquery2 = db_select('tab2','t2');
$subquery2->fields('t2',array('id','fname');
$subquery1->condition('t2.lname', 'Sinatra')
          ->orderBy('t2.fname','DESC');

$query = Database::getConnection()
  ->select($subquery1->union($subquery2))
  ->fields(NULL, array('id','fname'))
added 4 characters in body
Source Link
xurshid29
  • 2.5k
  • 15
  • 13

I don't know this will help, but you can try:

$subquery1 = db_select('tab1','t1');
$subquery1->fields('t1',array('id','fname');
$subquery1->condition('t1.fname', 'Frank')

$subquery2 = db_select('tab2','t2');
$subquery2->fields('t2',array('id','fname');
$subquery1->condition('t2.lname', 'Sinatra')
$subquery2->orderBy('t2.fname','DESC');

$subquery1->union($subquery2, 'UNION''UNION ALL');

$result = $subquery1->execute();
...

I don't know this will help, but you can try:

$subquery1 = db_select('tab1','t1');
$subquery1->fields('t1',array('id','fname');
$subquery1->condition('t1.fname', 'Frank')

$subquery2 = db_select('tab2','t2');
$subquery2->fields('t2',array('id','fname');
$subquery1->condition('t2.lname', 'Sinatra')
$subquery2->orderBy('t2.fname','DESC');

$subquery1->union($subquery2, 'UNION');

$result = $subquery1->execute();
...

I don't know this will help, but you can try:

$subquery1 = db_select('tab1','t1');
$subquery1->fields('t1',array('id','fname');
$subquery1->condition('t1.fname', 'Frank')

$subquery2 = db_select('tab2','t2');
$subquery2->fields('t2',array('id','fname');
$subquery1->condition('t2.lname', 'Sinatra')
$subquery2->orderBy('t2.fname','DESC');

$subquery1->union($subquery2, 'UNION ALL');

$result = $subquery1->execute();
...
Source Link
xurshid29
  • 2.5k
  • 15
  • 13

I don't know this will help, but you can try:

$subquery1 = db_select('tab1','t1');
$subquery1->fields('t1',array('id','fname');
$subquery1->condition('t1.fname', 'Frank')

$subquery2 = db_select('tab2','t2');
$subquery2->fields('t2',array('id','fname');
$subquery1->condition('t2.lname', 'Sinatra')
$subquery2->orderBy('t2.fname','DESC');

$subquery1->union($subquery2, 'UNION');

$result = $subquery1->execute();
...