Réécrivez le titre comme suit : Comment convertir les requêtes Union en Laravel
P粉819937486
P粉819937486 2023-09-15 16:56:54
0
1
536

Comment convertir cette requête en Laravel ? S'il vous plaît, aidez

SELECT 
* 
FROM
(SELECT 
    xxx_details.xxx_id AS id,
    'xxx' AS restult_type,
    start_time,
    (
        MATCH (
            xxx_search_tags.xxx_search_tag
        ) AGAINST ('test') * 10
    ) + (
        MATCH (
            xxx_search_tags.xxx_search_tag
        ) AGAINST ('search') * 10
    ) AS relevance 
FROM
    xxx_details        
WHERE xxx_status = 'active'        
    AND MATCH (
        xxx_search_tags.xxx_search_tag
    ) AGAINST ('\'test search\'*' IN BOOLEAN MODE) 
    AND privacy_type = 'public' 
GROUP BY xxx_details.xxx_id 
UNION
SELECT 
    yyy_details.yyy_id AS id,
    'yyy' AS restult_type,
    start_time,
    (
        MATCH (
            yyy_details.yyy_name               
        ) AGAINST ('test') * 10
    ) + (
        MATCH (
            yyy_details.yyy_name              
        ) AGAINST ('search') * 10
    ) AS relevance 
FROM
    yyy_details 
    
WHERE yyy_status = 'active'
    AND MATCH (
        yyy_details.yyy_name,yyy_details.yyy_desc
    ) AGAINST ('\'test search\'*' IN BOOLEAN MODE) 
GROUP BY yyy_details.yyy_id)  
ORDER BY relevance DESC,
start_time ASC
P粉819937486
P粉819937486

répondre à tous(1)
P粉323050780

Essayez d'utiliser la méthode suivante pour interroger

$results = DB::select( DB::raw("SELECT * FROM some_table WHERE some_col = '$someVariable'") );
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal