Pedro Posada | Complex union query

Complex union query

Posted on April 3, 2008 - 3:12pm
<< 43 of 50 >>

Simple sample of a long mysql query I did for a module.

<?php

$sql
= db_query(
               
" SELECT * FROM
                ((SELECT field_pack_upc_value AS upc , nid FROM content_type_bar_code )
                UNION
                (SELECT field_box_upc_value AS upc , nid FROM content_type_bar_code )
                UNION
                (SELECT field_case_upc_value AS upc , nid FROM content_type_bar_code )
                ORDER BY upc, nid ) AS b WHERE SUBSTRING(upc,-6) LIKE '%s'
                AND nid != %d "
               
, $pack, $node->nid );

?>

Post new comment

The content of this field is kept private and will not be shown publicly.
Please solve the math question. This way we will know you are not a robot.